bug-gnu-utils
[Top][All Lists]
Advanced

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

Problems compiling grep 2.5 on HP-UX 11.00


From: Newton, Philip
Subject: Problems compiling grep 2.5 on HP-UX 11.00
Date: Tue, 7 Jan 2003 17:50:06 +0100

While trying to compile grep 2.5 on HP-UX 11.00 with HP's compiler, I got
the following error:

<quote>
cc -DHAVE_CONFIG_H -I. -I. -I.. -I../intl -I../lib
-DLOCALEDIR=\"/usr/local/share/locale\"    -g -c `test -f dfa.c || echo
'./'`dfa.c
cc: "dfa.c", line 1055: error 1521: Incorrect initialization.
cc: "dfa.c", line 1055: error 1521: Incorrect initialization.
cc: "dfa.c", line 1059: error 1521: Incorrect initialization.
gmake[2]: *** [dfa.o] Error 1
</quote>

Those lines are as follows:

<quote>
                      } else {
                        /* POSIX locales are painful - leave the decision to
libc */
                        char expr[6] = { '[', c, '-', c2, ']', '\0' }; /*
line 1055 */
                        regex_t re;
                        if (regcomp (&re, expr, case_fold ? REG_ICASE : 0)
== REG_NOERROR) {
                          for (c = 0; c < NOTCHAR; ++c) {
                            char buf[2] = { c, '\0' };                 /*
line 1059 */
                            regmatch_t mat;
                            if (regexec (&re, buf, 1, &mat, 0) ==
REG_NOERROR
                               && mat.rm_so == 0 && mat.rm_eo == 1)
                              setbit_case_fold (c, ccl);
                          }
                          regfree (&re);
                        }
                      }
</quote>

"c" and "c2" are of type "unsigned". Explicitly casting those to "(char)"
didn't cause the compiler error to go away. What worked was changing those
lines to:

<quote>
                      } else {
                        /* POSIX locales are painful - leave the decision to
libc */
                        char expr[6] = { '[', 'X', '-', 'X', ']', '\0' };
                        expr[1] = c;
                        expr[3] = c2;
                        regex_t re;
                        if (regcomp (&re, expr, case_fold ? REG_ICASE : 0)
== REG_NOERROR) {
                          for (c = 0; c < NOTCHAR; ++c) {
                            char buf[2] = { 'X', '\0' };
                            buf[0] = c;
                            regmatch_t mat;
                            if (regexec (&re, buf, 1, &mat, 0) ==
REG_NOERROR
                               && mat.rm_so == 0 && mat.rm_eo == 1)
                              setbit_case_fold (c, ccl);
                          }
                          regfree (&re);
                        }
                      }
</quote>

That is, not initialising the arrays with variables but only with constants
and then overwriting the appropriate array elements with the variables.

I don't know whether the compiler is right or wrong to refuse that
construction, but since it has problems with it I suggest you replace the
code with something like the above.

Cheers,
Philip
-- 
Philip Newton <address@hidden>
All opinions are my own, not my employer's.
If you're not part of the solution, you're part of the precipitate.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]