2000-04-27 22:03:57 +02:00
|
|
|
/**********
|
|
|
|
|
Copyright 1990 Regents of the University of California. All rights reserved.
|
|
|
|
|
Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
|
|
|
|
|
**********/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
* Various things for quoting words. If this is not ascii, quote and
|
|
|
|
|
* strip are no-ops, so '' and \ quoting won't work. To fix this, sell
|
|
|
|
|
* your IBM machine and buy a vax.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "ngspice.h"
|
|
|
|
|
#include "cpdefs.h"
|
|
|
|
|
#include "quote.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Strip all the 8th bits from a string (destructively). */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
cp_wstrip(char *str)
|
|
|
|
|
{
|
2000-07-18 20:07:16 +02:00
|
|
|
char c, d;
|
2000-04-27 22:03:57 +02:00
|
|
|
|
|
|
|
|
if (str)
|
|
|
|
|
while ((c = *str)) { /* assign and test */
|
2010-11-02 18:31:19 +01:00
|
|
|
d = (char) strip(c);
|
2000-04-27 22:03:57 +02:00
|
|
|
if (c != d)
|
|
|
|
|
*str = d;
|
|
|
|
|
str++;
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Quote all characters in a word. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
cp_quoteword(char *str)
|
|
|
|
|
{
|
|
|
|
|
if (str)
|
|
|
|
|
while (*str) {
|
2010-11-02 18:31:19 +01:00
|
|
|
*str = (char) quote(*str);
|
2000-04-27 22:03:57 +02:00
|
|
|
str++;
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Print a word (strip the word first). */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
cp_printword(char *string, FILE *fp)
|
|
|
|
|
{
|
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
|
|
if (string)
|
|
|
|
|
for (s = string; *s; s++)
|
|
|
|
|
(void) putc((strip(*s)), fp);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* (Destructively) strip all the words in a wlist. */
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
cp_striplist(wordlist *wlist)
|
|
|
|
|
{
|
|
|
|
|
wordlist *wl;
|
|
|
|
|
|
|
|
|
|
for (wl = wlist; wl; wl = wl->wl_next)
|
|
|
|
|
cp_wstrip(wl->wl_word);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Remove the "" from a string. */
|
|
|
|
|
|
|
|
|
|
char *
|
|
|
|
|
cp_unquote(char *string)
|
|
|
|
|
{
|
|
|
|
|
char *s;
|
|
|
|
|
int l;
|
|
|
|
|
if (string) {
|
2003-07-23 21:36:39 +02:00
|
|
|
l = strlen(string);
|
2010-10-28 21:32:34 +02:00
|
|
|
s = TMALLOC(char, l + 1);
|
2003-07-23 21:36:39 +02:00
|
|
|
|
2010-09-19 16:09:12 +02:00
|
|
|
if (l>=2 && *string == '"' && string[l-1] == '"') {
|
2003-07-23 21:36:39 +02:00
|
|
|
strncpy(s,string+1,l-2);
|
|
|
|
|
s[l-2] = '\0';
|
|
|
|
|
} else
|
|
|
|
|
strcpy(s,string);
|
2000-04-27 22:03:57 +02:00
|
|
|
|
|
|
|
|
return (s);
|
|
|
|
|
} else
|
|
|
|
|
return 0;
|
|
|
|
|
}
|