aboutsummaryrefslogtreecommitdiff
path: root/pkg/utilities/nttools/copyone/addslash.x
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /pkg/utilities/nttools/copyone/addslash.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'pkg/utilities/nttools/copyone/addslash.x')
-rw-r--r--pkg/utilities/nttools/copyone/addslash.x32
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