Commit 29abe551 authored by Paul Eggert's avatar Paul Eggert

Port to C89.

* lib-src/ebrowse.c (USAGE): Remove macro with too-long string literal ...
(usage_message): ... and replace it with this new static constant
containing multiple literals.  All uses changed.
* lib-src/emacsclient.c (print_help_and_exit):
Rewrite to avoid string literals longer than the C89 limits.
(start_daemon_and_retry_set_socket):
Rewrite to avoid non-constant array initializer.
* lib-src/make-docfile.c (enum global_type): Omit trailing comma.
* src/bytecode.c (BYTE_CODE_THREADED): Do not define if __STRICT_ANSI__.
(B__dummy__): New dummy symbol, to pacify C89.
* src/dbusbind.c (XD_DEBUG_MESSAGE): Omit debugging on C89 hosts, since
they can't grok varargs macros.
* src/dispnew.c (add_window_display_history)
(add_frame_display_history):
* src/print.c (print_object):
* src/xdisp.c (debug_method_add):
Use %p printf format only for void pointers.
* src/emacs.c (usage_message): New constant, replacing ...
(USAGE1, USAGE2, USAGE3): Remove; they were too long for C89.
(main): Adjust to usage reorg.
* src/fns.c (syms_of_fns):
* src/profiler.c (syms_of_profiler):
Don't use non-constant struct initializers.
* src/gnutls.h (gnutls_initstage_t):
* src/lisp.h (enum Lisp_Fwd_Type):
* src/lread.c (lisp_file_lexically_bound_p):
* src/xsettings.c (anonymous enum):
Remove trailing comma.
* src/xsettings.c (apply_xft_settings): Use %f, not %lf; %lf is a C99ism.
* src/lisp.h (ENUM_BF): Use unsigned if pedantic.
(DEFUN_FUNCTION_INIT): New macro, that falls back on a cast if pre-C99.
(DEFUN): Use it.
* src/regex.c (const_re_char): New type, to pacify strict C89.
All uses of 'const re_char' replaced to use it.
* src/regex.h (_Restrict_): Rename from __restrict, to avoid clash
with glibc when strict C89.  This change is imported from gnulib.
All uses changed.
(_Restrict_arr_): Rename from __restrict_arr, similarly.
* src/sysdep.c (time_from_jiffies) [!HAVE_LONG_LONG_INT]:
Omit GNU_LINUX implementation, since it requires long long.
* src/xterm.c (x_draw_underwave):
Do not assume the traditional order of struct's members.
(x_term_init): Rewrite to avoid the need for non-constant structure
initializers.
parent 3d70c5cf
2013-07-10 Paul Eggert <eggert@cs.ucla.edu>
Port to C89.
* ebrowse.c (USAGE): Remove macro with too-long string literal ...
(usage_message): ... and replace it with this new static constant
containing multiple literals. All uses changed.
* emacsclient.c (print_help_and_exit):
Rewrite to avoid string literals longer than the C89 limits.
(start_daemon_and_retry_set_socket):
Rewrite to avoid non-constant array initializer.
* make-docfile.c (enum global_type): Omit trailing comma.
2013-07-02 Paul Eggert <eggert@cs.ucla.edu>
Prefer plain 'static' to 'static inline' (Bug#12541).
......
......@@ -3481,7 +3481,9 @@ open_file (char *file)
/* Display usage information and exit program. */
#define USAGE "\
static char const *const usage_message[] =
{
"\
Usage: ebrowse [options] {files}\n\
\n\
-a, --append append output to existing file\n\
......@@ -3489,6 +3491,8 @@ Usage: ebrowse [options] {files}\n\
-I, --search-path=LIST set search path for input files\n\
-m, --min-regexp-length=N set minimum regexp length to N\n\
-M, --max-regexp-length=N set maximum regexp length to N\n\
",
"\
-n, --no-nested-classes exclude nested classes\n\
-o, --output-file=FILE set output file name to FILE\n\
-p, --position-info print info about position in file\n\
......@@ -3498,12 +3502,16 @@ Usage: ebrowse [options] {files}\n\
-x, --no-regexps don't record regular expressions\n\
--help display this help\n\
--version display version info\n\
\n\
"
};
static _Noreturn void
usage (int error)
{
puts (USAGE);
int i;
for (i = 0; i < sizeof usage_message / sizeof *usage_message; i++)
fputs (usage_message[i], stdout);
exit (error ? EXIT_FAILURE : EXIT_SUCCESS);
}
......
......@@ -630,7 +630,7 @@ print_help_and_exit (void)
Please try to preserve them; otherwise the output is very hard to read
when using emacsclientw. */
message (FALSE,
"Usage: %s [OPTIONS] FILE...\n\
"Usage: %s [OPTIONS] FILE...\n%s%s%s", progname, "\
Tell the Emacs server to visit the specified files.\n\
Every FILE can be either just a FILENAME or [+LINE[:COLUMN]] FILENAME.\n\
\n\
......@@ -640,6 +640,7 @@ The following OPTIONS are accepted:\n\
-nw, -t, --tty Open a new Emacs frame on the current terminal\n\
-c, --create-frame Create a new frame instead of trying to\n\
use the current Emacs frame\n\
", "\
-F ALIST, --frame-parameters=ALIST\n\
Set the parameters of a new frame\n\
-e, --eval Evaluate the FILE arguments as ELisp expressions\n\
......@@ -647,6 +648,7 @@ The following OPTIONS are accepted:\n\
-q, --quiet Don't display messages on success\n\
-d DISPLAY, --display=DISPLAY\n\
Visit the file in the given display\n\
", "\
--parent-id=ID Open in parent window ID, via XEmbed\n"
#ifndef NO_SOCKETS_IN_FILE_SYSTEM
"-s SOCKET, --socket-name=SOCKET\n\
......@@ -661,7 +663,7 @@ The following OPTIONS are accepted:\n\
mode and try connecting again\n"
#endif /* not WINDOWSNT */
"\n\
Report bugs with M-x report-emacs-bug.\n", progname);
Report bugs with M-x report-emacs-bug.\n");
exit (EXIT_SUCCESS);
}
......@@ -1509,7 +1511,10 @@ start_daemon_and_retry_set_socket (void)
{
char emacs[] = "emacs";
char daemon_option[] = "--daemon";
char *d_argv[] = {emacs, daemon_option, 0 };
char *d_argv[3];
d_argv[0] = emacs;
d_argv[1] = daemon_option;
d_argv[2] = 0;
if (socket_name != NULL)
{
/* Pass --daemon=socket_name as argument. */
......
......@@ -555,7 +555,7 @@ enum global_type
LISP_OBJECT,
EMACS_INTEGER,
BOOLEAN,
FUNCTION,
FUNCTION
};
/* A single global. */
......
2013-07-10 Paul Eggert <eggert@cs.ucla.edu>
Port to C89.
* bytecode.c (BYTE_CODE_THREADED): Do not define if __STRICT_ANSI__.
(B__dummy__): New dummy symbol, to pacify C89.
* dbusbind.c (XD_DEBUG_MESSAGE): Omit debugging on C89 hosts, since
they can't grok varargs macros.
* dispnew.c (add_window_display_history)
(add_frame_display_history):
* print.c (print_object):
* xdisp.c (debug_method_add):
Use %p printf format only for void pointers.
* emacs.c (usage_message): New constant, replacing ...
(USAGE1, USAGE2, USAGE3): Remove; they were too long for C89.
(main): Adjust to usage reorg.
* fns.c (syms_of_fns):
* profiler.c (syms_of_profiler):
Don't use non-constant struct initializers.
* gnutls.h (gnutls_initstage_t):
* lisp.h (enum Lisp_Fwd_Type):
* lread.c (lisp_file_lexically_bound_p):
* xsettings.c (anonymous enum):
Remove trailing comma.
* xsettings.c (apply_xft_settings): Use %f, not %lf; %lf is a C99ism.
* lisp.h (ENUM_BF): Use unsigned if pedantic.
(DEFUN_FUNCTION_INIT): New macro, that falls back on a cast if pre-C99.
(DEFUN): Use it.
* regex.c (const_re_char): New type, to pacify strict C89.
All uses of 'const re_char' replaced to use it.
* regex.h (_Restrict_): Rename from __restrict, to avoid clash
with glibc when strict C89. This change is imported from gnulib.
All uses changed.
(_Restrict_arr_): Rename from __restrict_arr, similarly.
* sysdep.c (time_from_jiffies) [!HAVE_LONG_LONG_INT]:
Omit GNU_LINUX implementation, since it requires long long.
* xterm.c (x_draw_underwave):
Do not assume the traditional order of struct's members.
(x_term_init): Rewrite to avoid the need for non-constant structure
initializers.
Syntax cleanup, mostly replacing macros with functions.
` This removes the need for the syntax_temp hack.
* search.c: Include syntax.h after buffer.h, since syntax.h uses BVAR.
......
......@@ -59,7 +59,8 @@ by Hallvard:
indirect threaded, using GCC's computed goto extension. This code,
as currently implemented, is incompatible with BYTE_CODE_SAFE and
BYTE_CODE_METER. */
#if defined (__GNUC__) && !defined (BYTE_CODE_SAFE) && !defined (BYTE_CODE_METER)
#if (defined __GNUC__ && !defined __STRICT_ANSI__ \
&& !defined BYTE_CODE_SAFE && !defined BYTE_CODE_METER)
#define BYTE_CODE_THREADED
#endif
......@@ -285,8 +286,10 @@ enum byte_code_op
#ifdef BYTE_CODE_SAFE
Bscan_buffer = 0153, /* No longer generated as of v18. */
Bset_mark = 0163 /* this loser is no longer generated as of v18 */
Bset_mark = 0163, /* this loser is no longer generated as of v18 */
#endif
B__dummy__ = 0 /* Pacify C89. */
};
/* Whether to maintain a `top' and `bottom' field in the stack frame. */
......
......@@ -142,7 +142,10 @@ static bool xd_in_read_queued_messages = 0;
} while (0)
#else /* !DBUS_DEBUG */
#define XD_DEBUG_MESSAGE(...) \
# if __STDC_VERSION__ < 199901
# define XD_DEBUG_MESSAGE (void) /* Pre-C99 compilers cannot debug. */
# else
# define XD_DEBUG_MESSAGE(...) \
do { \
if (!NILP (Vdbus_debug)) \
{ \
......@@ -151,7 +154,8 @@ static bool xd_in_read_queued_messages = 0;
message ("%s: %s", __func__, s); \
} \
} while (0)
#define XD_DEBUG_VALID_LISP_OBJECT_P(object)
# endif
# define XD_DEBUG_VALID_LISP_OBJECT_P(object)
#endif
/* Check whether TYPE is a basic DBusType. */
......
......@@ -213,6 +213,7 @@ static void
add_window_display_history (struct window *w, const char *msg, bool paused_p)
{
char *buf;
void *ptr = w;
if (history_idx >= REDISPLAY_HISTORY_SIZE)
history_idx = 0;
......@@ -222,7 +223,7 @@ add_window_display_history (struct window *w, const char *msg, bool paused_p)
snprintf (buf, sizeof redisplay_history[0].trace,
"%"pMu": window %p (`%s')%s\n%s",
history_tick++,
w,
ptr,
((BUFFERP (w->contents)
&& STRINGP (BVAR (XBUFFER (w->contents), name)))
? SSDATA (BVAR (XBUFFER (w->contents), name))
......@@ -240,6 +241,7 @@ static void
add_frame_display_history (struct frame *f, bool paused_p)
{
char *buf;
void *ptr = f;
if (history_idx >= REDISPLAY_HISTORY_SIZE)
history_idx = 0;
......@@ -248,7 +250,7 @@ add_frame_display_history (struct frame *f, bool paused_p)
sprintf (buf, "%"pMu": update frame %p%s",
history_tick++,
f, paused_p ? " ***paused***" : "");
ptr, paused_p ? " ***paused***" : "");
}
......
......@@ -201,10 +201,10 @@ int initial_argc;
static void sort_args (int argc, char **argv);
static void syms_of_emacs (void);
/* MSVC needs each string be shorter than 2048 bytes, so the usage
/* C89 needs each string be at most 509 characters, so the usage
strings below are split to not overflow this limit. */
#define USAGE1 "\
Usage: %s [OPTION-OR-FILENAME]...\n\
static char const *const usage_message[] =
{ "\
\n\
Run Emacs, the extensible, customizable, self-documenting real-time\n\
display editor. The recommended way to start Emacs for normal editing\n\
......@@ -215,11 +215,15 @@ read the main documentation for these command-line arguments.\n\
\n\
Initialization options:\n\
\n\
",
"\
--batch do not do interactive display; implies -q\n\
--chdir DIR change to directory DIR\n\
--daemon start a server in the background\n\
--debug-init enable Emacs Lisp debugger for init file\n\
--display, -d DISPLAY use X server DISPLAY\n\
",
"\
--no-desktop do not load a saved desktop\n\
--no-init-file, -q load neither ~/.emacs nor default.el\n\
--no-shared-memory, -nl do not use shared memory\n\
......@@ -227,14 +231,16 @@ Initialization options:\n\
--no-site-lisp, -nsl do not add site-lisp directories to load-path\n\
--no-splash do not display a splash screen on startup\n\
--no-window-system, -nw do not communicate with X, ignoring $DISPLAY\n\
",
"\
--quick, -Q equivalent to:\n\
-q --no-site-file --no-site-lisp --no-splash\n\
--script FILE run FILE as an Emacs Lisp script\n\
--terminal, -t DEVICE use DEVICE for terminal I/O\n\
--user, -u USER load ~USER/.emacs instead of your own\n\
\n%s"
#define USAGE2 "\
\n\
",
"\
Action options:\n\
\n\
FILE visit FILE using find-file\n\
......@@ -243,6 +249,8 @@ FILE visit FILE using find-file\n\
--directory, -L DIR add DIR to variable load-path\n\
--eval EXPR evaluate Emacs Lisp expression EXPR\n\
--execute EXPR evaluate Emacs Lisp expression EXPR\n\
",
"\
--file FILE visit FILE using find-file\n\
--find-file FILE visit FILE using find-file\n\
--funcall, -f FUNC call Emacs Lisp function FUNC with no arguments\n\
......@@ -250,9 +258,9 @@ FILE visit FILE using find-file\n\
--kill exit without asking for confirmation\n\
--load, -l FILE load Emacs Lisp FILE using the load function\n\
--visit FILE visit FILE using find-file\n\
\n"
#define USAGE3 "\
\n\
",
"\
Display options:\n\
\n\
--background-color, -bg COLOR window background color\n\
......@@ -260,6 +268,8 @@ Display options:\n\
used for debugging Emacs\n\
--border-color, -bd COLOR main border color\n\
--border-width, -bw WIDTH width of main border\n\
",
"\
--color, --color=MODE override color mode for character terminals;\n\
MODE defaults to `auto', and\n\
can also be `never', `always',\n\
......@@ -267,17 +277,23 @@ Display options:\n\
--cursor-color, -cr COLOR color of the Emacs cursor indicating point\n\
--font, -fn FONT default font; must be fixed-width\n\
--foreground-color, -fg COLOR window foreground color\n\
",
"\
--fullheight, -fh make the first frame high as the screen\n\
--fullscreen, -fs make the first frame fullscreen\n\
--fullwidth, -fw make the first frame wide as the screen\n\
--maximized, -mm make the first frame maximized\n\
--geometry, -g GEOMETRY window geometry\n\
",
"\
--no-bitmap-icon, -nbi do not use picture of gnu for Emacs icon\n\
--iconic start Emacs in iconified state\n\
--internal-border, -ib WIDTH width between text and main border\n\
--line-spacing, -lsp PIXELS additional space to put between lines\n\
--mouse-color, -ms COLOR mouse cursor color in Emacs window\n\
--name NAME title for initial Emacs frame\n\
",
"\
--no-blinking-cursor, -nbc disable blinking cursor\n\
--reverse-video, -r, -rv switch foreground and background\n\
--title, -T TITLE title for initial Emacs frame\n\
......@@ -286,9 +302,9 @@ Display options:\n\
--parent-id XID set parent window\n\
--help display this help and exit\n\
--version output version information and exit\n\
\n"
#define USAGE4 "\
\n\
",
"\
You can generally also specify long option names with a single -; for\n\
example, -batch as well as --batch. You can use any unambiguous\n\
abbreviation for a --option.\n\
......@@ -298,6 +314,7 @@ Emacs' operation. See the main documentation.\n\
\n\
Report bugs to bug-gnu-emacs@gnu.org. First, please see the Bugs\n\
section of the Emacs manual or the file BUGS.\n"
};
/* True if handling a fatal error already. */
......@@ -934,9 +951,10 @@ main (int argc, char **argv)
/* Handle the --help option, which gives a usage message. */
if (argmatch (argv, argc, "-help", "--help", 3, NULL, &skip_args))
{
printf (USAGE1, argv[0], USAGE2);
printf (USAGE3);
printf (USAGE4);
int i;
printf ("Usage: %s [OPTION-OR-FILENAME]...\n", argv[0]);
for (i = 0; i < sizeof usage_message / sizeof *usage_message; i++)
fputs (usage_message[i], stdout);
exit (0);
}
......
......@@ -5011,13 +5011,21 @@ this variable. */);
defsubr (&Ssecure_hash);
defsubr (&Slocale_info);
{
struct hash_table_test
eq = { Qeq, Qnil, Qnil, NULL, hashfn_eq },
eql = { Qeql, Qnil, Qnil, cmpfn_eql, hashfn_eql },
equal = { Qequal, Qnil, Qnil, cmpfn_equal, hashfn_equal };
hashtest_eq = eq;
hashtest_eql = eql;
hashtest_equal = equal;
}
hashtest_eq.name = Qeq;
hashtest_eq.user_hash_function = Qnil;
hashtest_eq.user_cmp_function = Qnil;
hashtest_eq.cmpfn = 0;
hashtest_eq.hashfn = hashfn_eq;
hashtest_eql.name = Qeql;
hashtest_eql.user_hash_function = Qnil;
hashtest_eql.user_cmp_function = Qnil;
hashtest_eql.cmpfn = cmpfn_eql;
hashtest_eql.hashfn = hashfn_eql;
hashtest_equal.name = Qequal;
hashtest_equal.user_hash_function = Qnil;
hashtest_equal.user_cmp_function = Qnil;
hashtest_equal.cmpfn = cmpfn_equal;
hashtest_equal.hashfn = hashfn_equal;
}
......@@ -42,7 +42,7 @@ typedef enum
GNUTLS_STAGE_TRANSPORT_POINTERS_SET,
GNUTLS_STAGE_HANDSHAKE_TRIED,
GNUTLS_STAGE_READY,
GNUTLS_STAGE_READY
} gnutls_initstage_t;
#define GNUTLS_EMACS_ERROR_NOT_LOADED GNUTLS_E_APPLICATION_ERROR_MIN + 1
......
......@@ -363,9 +363,9 @@ enum enum_USE_LSB_TAG { USE_LSB_TAG = 0 };
#define INTMASK (EMACS_INT_MAX >> (INTTYPEBITS - 1))
#define case_Lisp_Int case Lisp_Int0: case Lisp_Int1
/* Idea stolen from GDB. MSVC doesn't support enums in bitfields,
and xlc complains vociferously about them. */
#if defined _MSC_VER || defined __IBMC__
/* Idea stolen from GDB. Pedantic GCC complains about enum bitfields,
MSVC doesn't support them, and xlc complains vociferously about them. */
#if defined __STRICT_ANSI__ || defined _MSC_VER || defined __IBMC__
#define ENUM_BF(TYPE) unsigned int
#else
#define ENUM_BF(TYPE) enum TYPE
......@@ -398,7 +398,7 @@ enum Lisp_Type
/* Cons. XCONS (object) points to a struct Lisp_Cons. */
Lisp_Cons = 6,
Lisp_Float = 7,
Lisp_Float = 7
};
/* This is the set of data types that share a common structure.
......@@ -428,7 +428,7 @@ enum Lisp_Fwd_Type
Lisp_Fwd_Bool, /* Fwd to a C boolean var. */
Lisp_Fwd_Obj, /* Fwd to a C Lisp_Object variable. */
Lisp_Fwd_Buffer_Obj, /* Fwd to a Lisp_Object field of buffers. */
Lisp_Fwd_Kboard_Obj, /* Fwd to a Lisp_Object field of kboards. */
Lisp_Fwd_Kboard_Obj /* Fwd to a Lisp_Object field of kboards. */
};
/* If you want to define a new Lisp data type, here are some
......@@ -2540,11 +2540,16 @@ CHECK_NUMBER_CDR (Lisp_Object x)
minargs, maxargs, lname, intspec, 0}; \
Lisp_Object fnname
#else /* not _MSC_VER */
# if __STDC_VERSION__ < 199901
# define DEFUN_FUNCTION_INIT(fnname, maxargs) (Lisp_Object (*) (void)) fnname
# else
# define DEFUN_FUNCTION_INIT(fnname, maxargs) .a ## maxargs = fnname
# endif
#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \
Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \
static struct Lisp_Subr alignas (GCALIGNMENT) sname = \
{ { PVEC_SUBR << PSEUDOVECTOR_AREA_BITS }, \
{ .a ## maxargs = fnname }, \
{ DEFUN_FUNCTION_INIT (fnname, maxargs) }, \
minargs, maxargs, lname, intspec, 0}; \
Lisp_Object fnname
#endif
......
......@@ -823,7 +823,7 @@ lisp_file_lexically_bound_p (Lisp_Object readcharfun)
{
bool rv = 0;
enum {
NOMINAL, AFTER_FIRST_DASH, AFTER_ASTERIX,
NOMINAL, AFTER_FIRST_DASH, AFTER_ASTERIX
} beg_end_state = NOMINAL;
bool in_file_vars = 0;
......
......@@ -1765,9 +1765,8 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
}
else if (WINDOWP (obj))
{
int len;
strout ("#<window ", -1, -1, printcharfun);
len = sprintf (buf, "%p", XWINDOW (obj));
void *ptr = XWINDOW (obj);
int len = sprintf (buf, "#<window %p", ptr);
strout (buf, len, len, printcharfun);
if (BUFFERP (XWINDOW (obj)->contents))
{
......@@ -1798,6 +1797,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
ptrdiff_t real_size, size;
int len;
#if 0
void *ptr = h;
strout ("#<hash-table", -1, -1, printcharfun);
if (SYMBOLP (h->test))
{
......@@ -1810,9 +1810,8 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
len = sprintf (buf, "%"pD"d/%"pD"d", h->count, ASIZE (h->next));
strout (buf, len, len, printcharfun);
}
len = sprintf (buf, " %p", h);
len = sprintf (buf, " %p>", ptr);
strout (buf, len, len, printcharfun);
PRINTCHAR ('>');
#endif
/* Implement a readable output, e.g.:
#s(hash-table size 2 test equal data (k1 v1 k2 v2)) */
......@@ -1892,6 +1891,7 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
else if (FRAMEP (obj))
{
int len;
void *ptr = XFRAME (obj);
Lisp_Object frame_name = XFRAME (obj)->name;
strout ((FRAME_LIVE_P (XFRAME (obj))
......@@ -1907,9 +1907,8 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
frame_name = build_string ("*INVALID*FRAME*NAME*");
}
print_string (frame_name, printcharfun);
len = sprintf (buf, " %p", XFRAME (obj));
len = sprintf (buf, " %p>", ptr);
strout (buf, len, len, printcharfun);
PRINTCHAR ('>');
}
else if (FONTP (obj))
{
......
......@@ -568,12 +568,12 @@ to make room for new entries. */);
profiler_log_size = 10000;
DEFSYM (Qprofiler_backtrace_equal, "profiler-backtrace-equal");
{
struct hash_table_test test
= { Qprofiler_backtrace_equal, Qnil, Qnil,
cmpfn_profiler, hashfn_profiler };
hashtest_profiler = test;
}
hashtest_profiler.name = Qprofiler_backtrace_equal;
hashtest_profiler.user_hash_function = Qnil;
hashtest_profiler.user_cmp_function = Qnil;
hashtest_profiler.cmpfn = cmpfn_profiler;
hashtest_profiler.hashfn = hashfn_profiler;
defsubr (&Sfunction_equal);
......
......@@ -531,8 +531,10 @@ init_syntax_once (void)
/* Type of source-pattern and string chars. */
#ifdef _MSC_VER
typedef unsigned char re_char;
typedef const re_char const_re_char;
#else
typedef const unsigned char re_char;
typedef re_char const_re_char;
#endif
typedef char boolean;
......@@ -2015,7 +2017,7 @@ struct range_table_work_area
/* Map a string to the char class it names (if any). */
re_wctype_t
re_wctype (const re_char *str)
re_wctype (const_re_char *str)
{
const char *string = (const char *) str;
if (STREQ (string, "alnum")) return RECC_ALNUM;
......@@ -2409,7 +2411,8 @@ do { \
} while (0)
static reg_errcode_t
regex_compile (const re_char *pattern, size_t size, reg_syntax_t syntax, struct re_pattern_buffer *bufp)
regex_compile (const_re_char *pattern, size_t size, reg_syntax_t syntax,
struct re_pattern_buffer *bufp)
{
/* We fetch characters from PATTERN here. */
register re_wchar_t c, c1;
......@@ -3765,7 +3768,7 @@ insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, unsigned cha
least one character before the ^. */
static boolean
at_begline_loc_p (const re_char *pattern, const re_char *p, reg_syntax_t syntax)
at_begline_loc_p (const_re_char *pattern, const_re_char *p, reg_syntax_t syntax)
{
re_char *prev = p - 2;
boolean odd_backslashes;
......@@ -3806,7 +3809,7 @@ at_begline_loc_p (const re_char *pattern, const re_char *p, reg_syntax_t syntax)
at least one character after the $, i.e., `P < PEND'. */
static boolean
at_endline_loc_p (const re_char *p, const re_char *pend, reg_syntax_t syntax)
at_endline_loc_p (const_re_char *p, const_re_char *pend, reg_syntax_t syntax)
{
re_char *next = p;
boolean next_backslash = *next == '\\';
......@@ -3850,7 +3853,8 @@ group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum)
Return -1 if fastmap was not updated accurately. */
static int
analyse_first (const re_char *p, const re_char *pend, char *fastmap, const int multibyte)
analyse_first (const_re_char *p, const_re_char *pend, char *fastmap,
const int multibyte)
{
int j, k;
boolean not;
......@@ -4594,7 +4598,7 @@ static int bcmp_translate (re_char *s1, re_char *s2,
/* If the operation is a match against one or more chars,
return a pointer to the next operation, else return NULL. */
static re_char *
skip_one_char (const re_char *p)
skip_one_char (const_re_char *p)
{
switch (*p++)
{
......@@ -4636,7 +4640,7 @@ skip_one_char (const re_char *p)
/* Jump over non-matching operations. */
static re_char *
skip_noops (const re_char *p, const re_char *pend)
skip_noops (const_re_char *p, const_re_char *pend)
{
int mcnt;
while (p < pend)
......@@ -4663,7 +4667,8 @@ skip_noops (const re_char *p, const re_char *pend)
/* Non-zero if "p1 matches something" implies "p2 fails". */
static int
mutually_exclusive_p (struct re_pattern_buffer *bufp, const re_char *p1, const re_char *p2)
mutually_exclusive_p (struct re_pattern_buffer *bufp, const_re_char *p1,
const_re_char *p2)
{
re_opcode_t op2;
const boolean multibyte = RE_MULTIBYTE_P (bufp);
......@@ -4922,8 +4927,8 @@ WEAK_ALIAS (__re_match_2, re_match_2)
/* This is a separate function so that we can force an alloca cleanup
afterwards. */
static regoff_t
re_match_2_internal (struct re_pattern_buffer *bufp, const re_char *string1,
size_t size1, const re_char *string2, size_t size2,
re_match_2_internal (struct re_pattern_buffer *bufp, const_re_char *string1,
size_t size1, const_re_char *string2, size_t size2,
ssize_t pos, struct re_registers *regs, ssize_t stop)
{
/* General temporaries. */
......@@ -6265,7 +6270,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const re_char *string1,
bytes; nonzero otherwise. */
static int
bcmp_translate (const re_char *s1, const re_char *s2, register ssize_t len,
bcmp_translate (const_re_char *s1, const_re_char *s2, register ssize_t len,
RE_TRANSLATE_TYPE translate, const int target_multibyte)
{
register re_char *p1 = s1, *p2 = s2;
......@@ -6434,7 +6439,7 @@ re_exec (const char *s)
the return codes and their meanings.) */
reg_errcode_t
regcomp (regex_t *__restrict preg, const char *__restrict pattern,
regcomp (regex_t *_Restrict_ preg, const char *_Restrict_ pattern,
int cflags)
{
reg_errcode_t ret;
......@@ -6515,8 +6520,8 @@ WEAK_ALIAS (__regcomp, regcomp)
We return 0 if we find a match and REG_NOMATCH if not. */
reg_errcode_t
regexec (const regex_t *__restrict preg, const char *__restrict string,
size_t nmatch, regmatch_t pmatch[__restrict_arr], int eflags)
regexec (const regex_t *_Restrict_ preg, const char *_Restrict_ string,
size_t nmatch, regmatch_t pmatch[_Restrict_arr_], int eflags)
{
regoff_t ret;
struct re_registers regs;
......
......@@ -528,31 +528,41 @@ extern int re_exec (const char *);
#endif
/* GCC 2.95 and later have "__restrict"; C99 compilers have
"restrict", and "configure" may have defined "restrict". */
#ifndef __restrict
# if ! (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95))
# if defined restrict || 199901L <= __STDC_VERSION__
# define __restrict restrict
# else
# define __restrict
# endif
"restrict", and "configure" may have defined "restrict".