|
@@ -479,19 +479,20 @@ map_name( const char *arg, char **result, int reserve, const char *in, const cha
|
|
char *p;
|
|
char *p;
|
|
int i, l, ll, num, inl, outl;
|
|
int i, l, ll, num, inl, outl;
|
|
|
|
|
|
|
|
+ assert( arg );
|
|
l = strlen( arg );
|
|
l = strlen( arg );
|
|
- if (!in) {
|
|
|
|
|
|
+ assert( in );
|
|
|
|
+ inl = strlen( in );
|
|
|
|
+ if (!inl) {
|
|
copy:
|
|
copy:
|
|
*result = nfmalloc( reserve + l + 1 );
|
|
*result = nfmalloc( reserve + l + 1 );
|
|
memcpy( *result + reserve, arg, l + 1 );
|
|
memcpy( *result + reserve, arg, l + 1 );
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
- inl = strlen( in );
|
|
|
|
- if (out) {
|
|
|
|
- outl = strlen( out );
|
|
|
|
- if (inl == outl && !memcmp( in, out, inl ))
|
|
|
|
- goto copy;
|
|
|
|
- }
|
|
|
|
|
|
+ assert( out );
|
|
|
|
+ outl = strlen( out );
|
|
|
|
+ if (equals( in, inl, out, outl ))
|
|
|
|
+ goto copy;
|
|
for (num = 0, i = 0; i < l; ) {
|
|
for (num = 0, i = 0; i < l; ) {
|
|
for (ll = 0; ll < inl; ll++)
|
|
for (ll = 0; ll < inl; ll++)
|
|
if (arg[i + ll] != in[ll])
|
|
if (arg[i + ll] != in[ll])
|
|
@@ -500,7 +501,7 @@ map_name( const char *arg, char **result, int reserve, const char *in, const cha
|
|
i += inl;
|
|
i += inl;
|
|
continue;
|
|
continue;
|
|
fout:
|
|
fout:
|
|
- if (out) {
|
|
|
|
|
|
+ if (outl) {
|
|
for (ll = 0; ll < outl; ll++)
|
|
for (ll = 0; ll < outl; ll++)
|
|
if (arg[i + ll] != out[ll])
|
|
if (arg[i + ll] != out[ll])
|
|
goto fnexti;
|
|
goto fnexti;
|
|
@@ -511,7 +512,7 @@ map_name( const char *arg, char **result, int reserve, const char *in, const cha
|
|
}
|
|
}
|
|
if (!num)
|
|
if (!num)
|
|
goto copy;
|
|
goto copy;
|
|
- if (!out)
|
|
|
|
|
|
+ if (!outl)
|
|
return -2;
|
|
return -2;
|
|
*result = nfmalloc( reserve + l + num * (outl - inl) + 1 );
|
|
*result = nfmalloc( reserve + l + num * (outl - inl) + 1 );
|
|
p = *result + reserve;
|
|
p = *result + reserve;
|
|
@@ -519,15 +520,7 @@ map_name( const char *arg, char **result, int reserve, const char *in, const cha
|
|
for (ll = 0; ll < inl; ll++)
|
|
for (ll = 0; ll < inl; ll++)
|
|
if (arg[i + ll] != in[ll])
|
|
if (arg[i + ll] != in[ll])
|
|
goto rnexti;
|
|
goto rnexti;
|
|
-#ifdef __GNUC__
|
|
|
|
-# pragma GCC diagnostic push
|
|
|
|
-/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42145 */
|
|
|
|
-# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
|
|
|
-#endif
|
|
|
|
memcpy( p, out, outl );
|
|
memcpy( p, out, outl );
|
|
-#ifdef __GNUC__
|
|
|
|
-# pragma GCC diagnostic pop
|
|
|
|
-#endif
|
|
|
|
p += outl;
|
|
p += outl;
|
|
i += inl;
|
|
i += inl;
|
|
continue;
|
|
continue;
|