static void convert_suffix_rule (char *target, char *source, struct commands *cmds) { char *targname, *targpercent, *depname; char **names, **percents; struct dep *deps; unsigned int len; if (target == 0) /* Special case: TARGET being nil means we are defining a `.X.a' suffix rule; the target pattern is always `(%.o)'. */ { #ifdef VMS targname = savestring ("(%.obj)", 7); #else targname = savestring ("(%.o)", 5); #endif targpercent = targname + 1; } else { /* Construct the target name. */ len = strlen (target); targname = xmalloc (1 + len + 1); targname[0] = '%'; bcopy (target, targname + 1, len + 1); targpercent = targname; } names = (char **) xmalloc (2 * sizeof (char *)); percents = (char **) alloca (2 * sizeof (char *)); names[0] = targname; percents[0] = targpercent; names[1] = percents[1] = 0; if (source == 0) deps = 0; else { /* Construct the dependency name. */ len = strlen (source); depname = xmalloc (1 + len + 1); depname[0] = '%'; bcopy (source, depname + 1, len + 1); deps = alloc_dep (); deps->name = depname; } create_pattern_rule (names, percents, 0, deps, cmds, 0); }
static void convert_suffix_rule (const char *target, const char *source, struct commands *cmds) { const char **names, **percents; struct dep *deps; names = xmalloc (sizeof (const char *)); percents = xmalloc (sizeof (const char *)); if (target == 0) { /* Special case: TARGET being nil means we are defining a '.X.a' suffix rule; the target pattern is always '(%.o)'. */ #ifdef VMS *names = strcache_add_len ("(%.obj)", 7); #else *names = strcache_add_len ("(%.o)", 5); #endif *percents = *names + 1; } else { /* Construct the target name. */ unsigned int len = strlen (target); char *p = alloca (1 + len + 1); p[0] = '%'; memcpy (p + 1, target, len + 1); *names = strcache_add_len (p, len + 1); *percents = *names; } if (source == 0) deps = 0; else { /* Construct the dependency name. */ unsigned int len = strlen (source); char *p = alloca (1 + len + 1); p[0] = '%'; memcpy (p + 1, source, len + 1); deps = alloc_dep (); deps->name = strcache_add_len (p, len + 1); } create_pattern_rule (names, percents, 1, 0, deps, cmds, 0); }