Commit bb715952 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

Initial revision

parent acbc1991
/{ .*$/s/{/{\
/ \?[^'] /s/?/?\
/ : /s/:/:\
/* Print which syntax bits are set. */
#include <sys/types.h>
#include <stdio.h>
#include "regex.h"
/* It's coincidental that these two are currently the same. */
/* Sum of above, when printed. Assigned in main. */
static unsigned longest;
static void
test_bit (syntax, bit, name)
reg_syntax_t syntax;
unsigned bit;
char *name;
char padding[100], test_str[100];
int padding_count;
sprintf (test_str, "%s (%d=0x%x)", name, bit, bit);
padding_count = longest - strlen (test_str);
padding[padding_count] = 0;
while (padding_count--)
padding[padding_count] = ' ';
printf ("%s%s (%d=0x%x): %c\n",
name, padding, bit, bit, syntax & bit ? 'y' : 'n');
/* Macro to abbreviate the constant arguments. */
#define TEST_BIT(bit) test_bit (syntax, bit, #bit)
main (argc, argv)
int argc;
char *argv[];
reg_syntax_t syntax;
char syntax_str[1000], test_str[100];
switch (argc)
case 1:
printf ("Syntax? ");
scanf ("%s", syntax_str);
case 2:
strcpy (syntax_str, argv[1]);
fprintf (stderr, "Usage: syntax [syntax].\n");
exit (1);
sscanf (syntax_str, "%i", &syntax);
/* Figure out the longest name, so we can align the output nicely. */
sprintf (test_str, "%s (%d=0x%x)", LONGEST_BIT_NAME, LAST_BIT, LAST_BIT);
longest = strlen (test_str);
/* [[[replace with bit tests]]] */
return 0;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment