X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Foutput%2Fafm.c;h=0eeaf4ee4f1d23455819d40e8534a3f183a62568;hb=0aadb06eaf7e641a1590e6296d79b06fe0f97609;hp=643ce87011c715cf786e4a455ee24f34958ac5dd;hpb=7a2039fb1ebfd48013ab259b28091e74e7f50588;p=pspp diff --git a/src/output/afm.c b/src/output/afm.c index 643ce87011..0eeaf4ee4f 100644 --- a/src/output/afm.c +++ b/src/output/afm.c @@ -1,6 +1,5 @@ /* PSPP - computes sample statistics. Copyright (C) 2006 Free Software Foundation, Inc. - Written by Ben Pfaff . This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -23,6 +22,7 @@ #include "c-strtod.h" #include #include +#include #include #include #include @@ -31,6 +31,7 @@ #include #include "error.h" #include "minmax.h" +#include #include #include @@ -720,11 +721,11 @@ get_word (struct parser *p, char **word) struct string s; int c; - ds_init (&s); + ds_init_empty (&s); while (!isspace (c = getc (p->file)) && c != EOF) - ds_putc (&s, c); + ds_put_char (&s, c); ungetc (c, p->file); - *word = ds_c_str (&s); + *word = ds_cstr (&s); pool_register (p->pool, free, *word); return true; } @@ -756,7 +757,7 @@ force_get_word (struct parser *p) static bool get_string (struct parser *p, char **string) { - struct string s = DS_INITIALIZER; + struct string s = DS_EMPTY_INITIALIZER; skip_spaces (p); for (;;) @@ -764,14 +765,14 @@ get_string (struct parser *p, char **string) int c = getc (p->file); if (c == EOF || c == '\n') break; - ds_putc (&s, c); + ds_put_char (&s, c); } ungetc ('\n', p->file); - ds_rtrim_spaces (&s); + ds_rtrim (&s, ss_cstr (CC_SPACES)); if (!ds_is_empty (&s)) { - *string = ds_c_str (&s); + *string = ds_cstr (&s); pool_register (p->pool, free, *string); return true; } @@ -874,7 +875,7 @@ static size_t encode_one_byte (const struct afm_character **s, size_t n, struct string *out) { - ds_putc (out, '('); + ds_put_char (out, '('); for (; n > 0; s++, n--) { uint8_t code = (*s)->code; @@ -882,13 +883,13 @@ encode_one_byte (const struct afm_character **s, size_t n, break; if (code == '(' || code == ')' || code == '\\') - ds_printf (out, "\\%c", code); + ds_put_format (out, "\\%c", code); else if (!c_isprint (code)) - ds_printf (out, "\\%03o", code); + ds_put_format (out, "\\%03o", code); else - ds_putc (out, code); + ds_put_char (out, code); } - ds_putc (out, ')'); + ds_put_char (out, ')'); return n; } @@ -935,7 +936,7 @@ append_ascii85_block (unsigned b, size_t n, struct string *out) c[i] = value_to_ascii85 (b % 85); b /= 85; } - ds_concat (out, c, n); + ds_put_substring (out, ss_buffer (c, n)); } /* Encodes BYTE with encoder E. */ @@ -947,12 +948,12 @@ binary_put (struct binary_encoder *e, uint8_t byte) if (e->n % 4 == 0) { if (e->n == 4) - ds_puts (e->out, "<~"); + ds_put_cstr (e->out, "<~"); if (e->b != 0) append_ascii85_block (e->b, 5, e->out); else - ds_putc (e->out, 'z'); + ds_put_char (e->out, 'z'); } } @@ -967,7 +968,7 @@ binary_finish (struct binary_encoder *e) size_t n = e->n % 4; if (n > 0) append_ascii85_block (e->b << 8 * (4 - n), n + 1, e->out); - ds_puts (e->out, "~>"); + ds_put_cstr (e->out, "~>"); } else if (e->n > 0) { @@ -976,19 +977,19 @@ binary_finish (struct binary_encoder *e) uint32_t b; size_t i; - ds_puts (e->out, "<"); + ds_put_cstr (e->out, "<"); b = e->b << 8 * (4 - e->n); for (i = 0; i < e->n; i++) { - ds_printf (e->out, "%02x", b >> 24); + ds_put_format (e->out, "%02x", b >> 24); b <<= 8; } - ds_puts (e->out, ">"); + ds_put_cstr (e->out, ">"); } else { /* Empty string. */ - ds_puts (e->out, "()"); + ds_put_cstr (e->out, "()"); } } @@ -1146,7 +1147,7 @@ afm_encode_string (const struct afm *afm, break; default: - abort (); + NOT_REACHED (); } binary_finish (&e); }