Commit 6d27ad25 authored by Niels Möller's avatar Niels Möller
Browse files

*** empty log message ***

Rev: src/sexp.c:1.7
Rev: src/sexp.h:1.8
parent 9b5cddae
......@@ -37,7 +37,9 @@
#undef CLASS_DEFINE
/* Defines int char_classes[0x100] */
#define CHAR_CLASSES_TABLE sexp_char_classes
#include "sexp_table.h"
#undef CHAR_CLASSES_TABLE
#include "sexp.c.x"
......@@ -76,9 +78,9 @@ static struct lsh_string *do_format_simple_string(struct lsh_string *s,
/* Compute the set of all character classes represented in the string */
for (c = 0, i = 0; i < s->length; i++)
c |= char_classes[s->data[i]];
c |= sexp_char_classes[s->data[i]];
if (! ( (char_classes[s->data[0]] & CHAR_digit)
if (! ( (sexp_char_classes[s->data[0]] & CHAR_digit)
|| (c & ~(CHAR_alpha | CHAR_digit | CHAR_punctuation))))
/* Output token, without any quoting at all */
return lsh_string_dup(s);
......@@ -92,12 +94,12 @@ static struct lsh_string *do_format_simple_string(struct lsh_string *s,
UINT8 *dst;
for (i = 0; i<s->length; i++)
if (char_classes[s->data[i]] & CHAR_escapable)
if (sexp_char_classes[s->data[i]] & CHAR_escapable)
length++;
res = ssh_format("\"%lr\"", length, &dst);
for (i=0; i<s->length; i++)
if (char_classes[s->data[i]] & CHAR_escapable)
if (sexp_char_classes[s->data[i]] & CHAR_escapable)
{
*dst++ = '\\';
switch(s->data[i])
......@@ -169,7 +171,7 @@ static struct lsh_string *do_format_sexp_string(struct sexp *s, int style)
}
/* Consumes its args (display may be NULL) */
static struct sexp *make_sexp_string(struct lsh_string *d, struct lsh_string *c)
struct sexp *make_sexp_string(struct lsh_string *d, struct lsh_string *c)
{
NEW(sexp_string, s);
......
......@@ -94,6 +94,10 @@ struct lsh_string *encode_base64(struct lsh_string *s,
int free);
/* Creating sexps */
/* Consumes its args (display may be NULL) */
struct sexp *make_sexp_string(struct lsh_string *d, struct lsh_string *c);
/* atom->sexp */
struct sexp *sexp_a(const int a);
......@@ -135,10 +139,11 @@ int sexp_atom(const struct sexp *e);
int sexp_bignum_u(const struct sexp *e, mpz_t n);
int sexp_bignum_s(const struct sexp *e, mpz_t n);
extern int sexp_char_classes[];
/* Parsing sexp */
/* ;;CLASS:
/* CLASS:
(class
(name sexp_handler)
(vars
......@@ -147,10 +152,6 @@ int sexp_bignum_s(const struct sexp *e, mpz_t n);
*/
#define HANDLE_SEXP(h, s) ((h)->handler((h), (s)))
#if 0
struct read_handler make_read_sexp(struct sexp_handler *h);
#endif
#endif /* LSH_SEXP_H_INCLUDED */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment