diff options
Diffstat (limited to 'pkg/utilities/nttools/copyone/addslash.x')
-rw-r--r-- | pkg/utilities/nttools/copyone/addslash.x | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/pkg/utilities/nttools/copyone/addslash.x b/pkg/utilities/nttools/copyone/addslash.x new file mode 100644 index 00000000..6c5c2ded --- /dev/null +++ b/pkg/utilities/nttools/copyone/addslash.x @@ -0,0 +1,32 @@ +# ADDSLASH -- Convert a string by prefixing quote marks with backslashes +# +# B.Simon 30-Sep-87 First Code + +procedure addslash (str, maxch) + +char str[ARB] # String to be converted +int maxch # Maximum length of string + +int i, j +pointer sp, aux + +begin + call smark (sp) + call salloc (aux, maxch, TY_CHAR) + + j = 1 + for (i = 1; (str[i] != EOS) && (j <= maxch); i = i + 1) { + if (str[i] == '"') { + if (j == maxch) + break + Memc[aux+j-1] = '\\' + j = j + 1 + } + Memc[aux+j-1] = str[i] + j = j + 1 + } + + Memc[aux+j-1] = EOS + call strcpy (Memc[aux], str, maxch) + call sfree (sp) +end |