aboutsummaryrefslogtreecommitdiffstats
path: root/apps/expand.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/expand.c')
-rw-r--r--apps/expand.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/apps/expand.c b/apps/expand.c
index a0ce888..8ce384d 100644
--- a/apps/expand.c
+++ b/apps/expand.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.3 2008/03/07 14:16:44 james
+ * *** empty log message ***
+ *
* Revision 1.2 2008/03/07 14:13:40 james
* *** empty log message ***
*
@@ -100,7 +103,7 @@ hex (const char **in)
(*in)++;
while (**in) {
- printf("%c %d\n",**in,x);
+ printf ("%c %d\n", **in, x);
if (!my_isxdigit (**in))
return x;
x <<= 4;
@@ -111,7 +114,7 @@ hex (const char **in)
}
char *
-expand (const char *in,int *len)
+expand (const char *in, int *len)
{
const char *iptr = in;
int l;
@@ -123,56 +126,57 @@ expand (const char *in,int *len)
l = strlen (in);
optr = ret = malloc (l + 1);
- if (!ret) return ret;
+ if (!ret)
+ return ret;
+
-
- l=0;
+ l = 0;
while (*iptr) {
if (*iptr == '\\') {
- iptr++;
+ iptr++;
switch (*iptr) {
case '\'':
case '\"':
case '\?':
case '\\':
*(optr++) = *(iptr++);
- l++;
+ l++;
break;
case 'a':
*(optr++) = '\a';
- l++;
+ l++;
iptr++;
break;
case 'b':
*(optr++) = '\b';
- l++;
+ l++;
iptr++;
break;
case 'f':
*(optr++) = '\f';
- l++;
+ l++;
iptr++;
break;
case 'n':
*(optr++) = '\n';
- l++;
+ l++;
iptr++;
break;
case 'r':
*(optr++) = '\r';
- l++;
+ l++;
iptr++;
break;
case 't':
*(optr++) = '\t';
- l++;
+ l++;
iptr++;
break;
case 'v':
*(optr++) = '\v';
- l++;
+ l++;
iptr++;
break;
case '0':
@@ -184,25 +188,26 @@ expand (const char *in,int *len)
case '6':
case '7':
*(optr++) = octal (&iptr);
- l++;
+ l++;
break;
case 'x':
*(optr++) = hex (&iptr);
- l++;
+ l++;
break;
default:
*(optr++) = '\\';
- l++;
+ l++;
*(optr++) = *(iptr++);
- l++;
+ l++;
}
} else {
*(optr++) = *(iptr++);
- l++;
+ l++;
}
}
- if (*len) *len=l;
+ if (*len)
+ *len = l;
*(optr++) = 0;