253 |
return (temp); |
return (temp); |
254 |
} |
} |
255 |
|
|
|
/* Gets the extension index in FILENAME. Returns 0 if fails to |
|
|
find an extension. */ |
|
|
static int |
|
|
get_extension_index (const char *filename) |
|
|
{ |
|
|
int len; |
|
|
|
|
|
len = strlen (filename); |
|
|
|
|
|
if (filename[len-- - 1] == '.') |
|
|
return (0); |
|
|
|
|
|
while ((len > 0) && (filename[len - 1] != '.')) |
|
|
if (filename[len - 1] == '/') |
|
|
return (0); |
|
|
else |
|
|
len--; |
|
|
|
|
|
return (len - 1); |
|
|
} |
|
|
|
|
256 |
/* Computes extensions from the grammar file extension. */ |
/* Computes extensions from the grammar file extension. */ |
257 |
static void |
static void |
258 |
compute_exts_from_gf (const char *ext) |
compute_exts_from_gf (const char *ext) |
317 |
/* If there is an exentension, check if there is a `.tab' part right |
/* If there is an exentension, check if there is a `.tab' part right |
318 |
before. */ |
before. */ |
319 |
if (*ext |
if (*ext |
320 |
&& (*ext - *base) > strlen (".tab") |
&& (*ext - *base) > (int) strlen (".tab") |
321 |
&& (!strncmp (*ext - strlen (".tab"), ".tab", strlen (".tab")) |
&& (!strncmp (*ext - strlen (".tab"), ".tab", strlen (".tab")) |
322 |
|| !strncmp (*ext - strlen ("_tab"), "_tab", strlen ("_tab")))) |
|| !strncmp (*ext - strlen ("_tab"), "_tab", strlen ("_tab")))) |
323 |
*tab = *ext - strlen (".tab"); |
*tab = *ext - strlen (".tab"); |
330 |
compute_base_names (void) |
compute_base_names (void) |
331 |
{ |
{ |
332 |
const char *base, *tab, *ext; |
const char *base, *tab, *ext; |
|
size_t base_length; |
|
|
size_t short_base_length; |
|
|
size_t ext_index; |
|
333 |
|
|
334 |
/* If --output=foo.c was specified (SPEC_OUTFILE == foo.c), |
/* If --output=foo.c was specified (SPEC_OUTFILE == foo.c), |
335 |
BASE_NAME and SHORT_BASE_NAME are `foo'. |
BASE_NAME and SHORT_BASE_NAME are `foo'. |
341 |
files, remove the ".c" or ".tab.c" suffix. */ |
files, remove the ".c" or ".tab.c" suffix. */ |
342 |
if (spec_outfile) |
if (spec_outfile) |
343 |
{ |
{ |
|
const char *cp; |
|
344 |
filename_split (spec_outfile, &base, &tab, &ext); |
filename_split (spec_outfile, &base, &tab, &ext); |
345 |
|
|
346 |
/* The full base name goes up the EXT, excluding it. */ |
/* The full base name goes up the EXT, excluding it. */ |