Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/dist/nvi/common



In article <20080611213218.03352175D0%cvs.netbsd.org@localhost>,
Aymeric Vincent  <aymeric%netbsd.org@localhost> wrote:
>
>Module Name:   src
>Committed By:  aymeric
>Date:          Wed Jun 11 21:32:17 UTC 2008
>
>Modified Files:
>       src/dist/nvi/common: gs.h
>
>Log Message:
>Fix a warning which breaks the build on a few platforms.
>XXX may be not the right thing to do, but very little intrusive

Yes, it is not the right thing to do :-) The following patch is probably
what the author intended. It simplifies the code in the non wide case, and
fixes a bug in the wide case too:

-           sp->gp->special_key[(UCHAR_T)ch] :                          \
+           sp->gp->special_key[(unsigned char)ch] :                    \

christos

Index: common/gs.h
===================================================================
RCS file: /cvsroot/src/dist/nvi/common/gs.h,v
retrieving revision 1.2
diff -u -u -r1.2 gs.h
--- common/gs.h 11 Jun 2008 21:32:17 -0000      1.2
+++ common/gs.h 12 Jun 2008 14:41:10 -0000
@@ -93,25 +93,35 @@
        LIST_HEAD(_seqh, _seq) seqq;    /* Linked list of maps, abbrevs. */
        bitstr_t bit_decl(seqb, MAX_BIT_SEQ);
 
-#define        MAX_FAST_KEY    254             /* Max fast check character.*/
+#define        MAX_FAST_KEY    255             /* Max fast check character.*/
+       struct {
+               u_char   name[MAX_CHARACTER_COLUMNS + 1];
+               u_int8_t len;
+       } cname[MAX_FAST_KEY + 1];      /* Fast lookup table. */
+       CHAR_T   max_special;           /* Max special character. */
+       u_char                          /* Fast lookup table. */
+           special_key[MAX_FAST_KEY + 1];
+
+#ifdef USE_WIDECHAR
 #define        KEY_LEN(sp, ch)                                                 
\
        ((UCHAR_T)(ch) <= MAX_FAST_KEY ?                        \
            sp->gp->cname[(unsigned char)ch].len : v_key_len(sp, ch))
 #define        KEY_NAME(sp, ch)                                                
\
        ((UCHAR_T)(ch) <= MAX_FAST_KEY ?                                \
            sp->gp->cname[(unsigned char)ch].name : v_key_name(sp, ch))
-       struct {
-               u_char   name[MAX_CHARACTER_COLUMNS + 1];
-               u_int8_t len;
-       } cname[MAX_FAST_KEY + 1];      /* Fast lookup table. */
 
 #define        KEY_VAL(sp, ch)                                                 
\
        ((UCHAR_T)(ch) <= MAX_FAST_KEY ?                                \
-           sp->gp->special_key[(UCHAR_T)ch] :                          \
+           sp->gp->special_key[(unsigned char)ch] :                    \
            (UCHAR_T)(ch) > sp->gp->max_special ? K_NOTUSED : v_key_val(sp,ch))
-       CHAR_T   max_special;           /* Max special character. */
-       u_char                          /* Fast lookup table. */
-           special_key[MAX_FAST_KEY + 1];
+#else
+#define        KEY_LEN(sp, ch)                                                 
\
+           sp->gp->cname[(unsigned char)ch].len
+#define        KEY_NAME(sp, ch)                                                
\
+           sp->gp->cname[(unsigned char)ch].name
+#define        KEY_VAL(sp, ch)                                                 
\
+           sp->gp->special_key[(unsigned char)ch];
+#endif
 
 /* Flags. */
 #define        G_ABBREV        0x0001          /* If have abbreviations. */



Home | Main Index | Thread Index | Old Index