/[m4]/m4/modules/gnu.c
ViewVC logotype

Diff of /m4/modules/gnu.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.16 by gary, Thu Oct 11 21:09:16 2001 UTC revision 1.17 by gary, Fri Oct 12 19:57:29 2001 UTC
# Line 67  int errno; Line 67  int errno;
67  /* Maintain each of the builtins implemented in this modules along  /* Maintain each of the builtins implemented in this modules along
68     with their details in a single table for easy maintenance.     with their details in a single table for easy maintenance.
69    
70                  function        macros  blind */                  function        macros  blind argmin  argmax */
71  #define builtin_functions                       \  #define builtin_functions                       \
72          BUILTIN(__file__,       FALSE,  FALSE ) \          BUILTIN(__file__,       FALSE,  FALSE,  1,      1  )    \
73          BUILTIN(__line__,       FALSE,  FALSE ) \          BUILTIN(__line__,       FALSE,  FALSE,  1,      1  )    \
74          BUILTIN(builtin,        FALSE,  TRUE  ) \          BUILTIN(builtin,        FALSE,  TRUE,   2,      -1 )    \
75          BUILTIN(changesyntax,   FALSE,  TRUE  ) \          BUILTIN(changesyntax,   FALSE,  TRUE,   1,      -1 )    \
76          BUILTIN(debugmode,      FALSE,  FALSE ) \          BUILTIN(debugmode,      FALSE,  FALSE,  1,      2  )    \
77          BUILTIN(debugfile,      FALSE,  FALSE ) \          BUILTIN(debugfile,      FALSE,  FALSE,  1,      2  )    \
78          BUILTIN(eregexp,        FALSE,  TRUE  ) \          BUILTIN(eregexp,        FALSE,  TRUE,   3,      4  )    \
79          BUILTIN(epatsubst,      FALSE,  TRUE  ) \          BUILTIN(epatsubst,      FALSE,  TRUE,   3,      4  )    \
80          BUILTIN(esyscmd,        FALSE,  TRUE  ) \          BUILTIN(esyscmd,        FALSE,  TRUE,   2,      2  )    \
81          BUILTIN(format,         FALSE,  TRUE  ) \          BUILTIN(format,         FALSE,  TRUE,   2,      -1 )    \
82          BUILTIN(indir,          FALSE,  TRUE  ) \          BUILTIN(indir,          FALSE,  TRUE,   2,      -1 )    \
83          BUILTIN(patsubst,       FALSE,  TRUE  ) \          BUILTIN(patsubst,       FALSE,  TRUE,   3,      4  )    \
84          BUILTIN(regexp,         FALSE,  TRUE  ) \          BUILTIN(regexp,         FALSE,  TRUE,   3,      4  )    \
85          BUILTIN(symbols,        FALSE,  FALSE ) \          BUILTIN(symbols,        FALSE,  FALSE,  0,      -1 )    \
86          BUILTIN(syncoutput,     FALSE,  TRUE  ) \          BUILTIN(syncoutput,     FALSE,  TRUE,   2,      2  )    \
87    
88    
89  /* Generate prototypes for each builtin handler function. */  /* Generate prototypes for each builtin handler function. */
90  #define BUILTIN(handler, macros,  blind)        M4BUILTIN(handler)  #define BUILTIN(handler, macros,  blind, min, max)  M4BUILTIN(handler)
91    builtin_functions    builtin_functions
92  #undef BUILTIN  #undef BUILTIN
93    
# Line 95  int errno; Line 95  int errno;
95  /* Generate a table for mapping m4 symbol names to handler functions. */  /* Generate a table for mapping m4 symbol names to handler functions. */
96  m4_builtin m4_builtin_table[] =  m4_builtin m4_builtin_table[] =
97  {  {
98  #define BUILTIN(handler, macros, blind)         \  #define BUILTIN(handler, macros, blind, min, max)               \
99          { STR(handler), CONC(builtin_, handler), macros, blind },          { STR(handler), CONC(builtin_, handler), macros, blind, min, max },
100    builtin_functions    builtin_functions
101  #undef BUILTIN  #undef BUILTIN
102    
103    { 0, 0, FALSE, FALSE },    { 0, 0, FALSE, FALSE, 0, 0 },
104  };  };
105    
106    
# Line 137  M4BUILTIN_HANDLER (builtin) Line 137  M4BUILTIN_HANDLER (builtin)
137    const m4_builtin *bp = NULL;    const m4_builtin *bp = NULL;
138    const char *name = M4ARG (1);    const char *name = M4ARG (1);
139    
   if (m4_bad_argc (argv[0], argc, 2, -1))  
     return;  
   
140    bp = m4_builtin_find_by_name (NULL, name);    bp = m4_builtin_find_by_name (NULL, name);
141    
142    if (bp == NULL)    if (bp == NULL)
# Line 163  M4BUILTIN_HANDLER (indir) Line 160  M4BUILTIN_HANDLER (indir)
160    m4_symbol *symbol;    m4_symbol *symbol;
161    const char *name = M4ARG (1);    const char *name = M4ARG (1);
162    
   if (m4_bad_argc (argv[0], argc, 2, -1))  
     return;  
   
163    symbol = m4_symbol_lookup (name);    symbol = m4_symbol_lookup (name);
164    if (symbol == NULL)    if (symbol == NULL)
165      M4ERROR ((warning_status, 0,      M4ERROR ((warning_status, 0,
# Line 187  M4BUILTIN_HANDLER (changesyntax) Line 181  M4BUILTIN_HANDLER (changesyntax)
181  {  {
182    int i;    int i;
183    
   if (m4_bad_argc (argv[0], argc, 1, -1))  
     return;  
   
184    for (i = 1; i < argc; i++)    for (i = 1; i < argc; i++)
185      {      {
186        m4_set_syntax (*M4ARG (i),        m4_set_syntax (*M4ARG (i),
# Line 209  M4BUILTIN_HANDLER (debugmode) Line 200  M4BUILTIN_HANDLER (debugmode)
200    int new_debug_level;    int new_debug_level;
201    int change_flag;    int change_flag;
202    
   if (m4_bad_argc (argv[0], argc, 1, 2))  
     return;  
   
203    if (argc == 1)    if (argc == 1)
204      debug_level = 0;      debug_level = 0;
205    else    else
# Line 258  M4BUILTIN_HANDLER (debugmode) Line 246  M4BUILTIN_HANDLER (debugmode)
246   **/   **/
247  M4BUILTIN_HANDLER (debugfile)  M4BUILTIN_HANDLER (debugfile)
248  {  {
   if (m4_bad_argc (argv[0], argc, 1, 2))  
     return;  
   
249    if (argc == 1)    if (argc == 1)
250      m4_debug_set_output (NULL);      m4_debug_set_output (NULL);
251    else if (!m4_debug_set_output (M4ARG (1)))    else if (!m4_debug_set_output (M4ARG (1)))
# Line 324  m4_regexp_do (struct obstack *obs, int a Line 309  m4_regexp_do (struct obstack *obs, int a
309    int startpos;                 /* start position of match */    int startpos;                 /* start position of match */
310    int length;                   /* length of first argument */    int length;                   /* length of first argument */
311    
   if (m4_bad_argc (argv[0], argc, 3, 4))  
     return;  
   
312    victim = M4ARG (1);    victim = M4ARG (1);
313    regexp = M4ARG (2);    regexp = M4ARG (2);
314    
# Line 499  M4BUILTIN_HANDLER (symbols) Line 481  M4BUILTIN_HANDLER (symbols)
481   **/   **/
482  M4BUILTIN_HANDLER (syncoutput)  M4BUILTIN_HANDLER (syncoutput)
483  {  {
   if (m4_bad_argc (argv[0], argc, 2, 2))  
     return;  
   
484    if (TOKEN_TYPE (argv[1]) != M4_TOKEN_TEXT)    if (TOKEN_TYPE (argv[1]) != M4_TOKEN_TEXT)
485      return;      return;
486    
# Line 524  M4BUILTIN_HANDLER (esyscmd) Line 503  M4BUILTIN_HANDLER (esyscmd)
503    FILE *pin;    FILE *pin;
504    int ch;    int ch;
505    
   if (m4_bad_argc (argv[0], argc, 2, 2))  
     return;  
   
506    m4_debug_flush_files ();    m4_debug_flush_files ();
507    pin = popen (M4ARG (1), "r");    pin = popen (M4ARG (1), "r");
508    if (pin == NULL)    if (pin == NULL)
# Line 560  M4BUILTIN_HANDLER (format) Line 536  M4BUILTIN_HANDLER (format)
536   **/   **/
537  M4BUILTIN_HANDLER (__file__)  M4BUILTIN_HANDLER (__file__)
538  {  {
   if (m4_bad_argc (argv[0], argc, 1, 1))  
     return;  
   
539    m4_shipout_string (obs, m4_current_file, 0, TRUE);    m4_shipout_string (obs, m4_current_file, 0, TRUE);
540  }  }
541    
# Line 572  M4BUILTIN_HANDLER (__file__) Line 545  M4BUILTIN_HANDLER (__file__)
545   **/   **/
546  M4BUILTIN_HANDLER (__line__)  M4BUILTIN_HANDLER (__line__)
547  {  {
   if (m4_bad_argc (argv[0], argc, 1, 1))  
     return;  
548    m4_shipout_int (obs, m4_current_line);    m4_shipout_int (obs, m4_current_line);
549  }  }
550    

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26