X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fformat.h;h=1f6f3fb993b8bed51f7fbc84eefae64af729f0d6;hb=92fb12eb06716d14c05b781f5d9dcde956d77c30;hp=a1a6e5c54ebe50931676244181376621326fba6c;hpb=6f972e0ef93c3a7e00fd5335ea22af2c878f4589;p=pspp diff --git a/src/format.h b/src/format.h index a1a6e5c54e..1f6f3fb993 100644 --- a/src/format.h +++ b/src/format.h @@ -14,19 +14,21 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ #if !format_h #define format_h 1 /* Display format types. */ + +#include + /* See the definitions of these functions and variables when modifying this list: misc.c:convert_fmt_ItoO() sfm-read.c:parse_format_spec() - data-in.c:parse_string_as_format() - data-out.c:convert_format_to_string(). */ + data-in.c:parse_string_as_format() */ #define DEFFMT(LABEL, NAME, N_ARGS, IMIN_W, IMAX_W, OMIN_W, OMAX_W, \ CAT, OUTPUT, SPSS_FMT) \ LABEL, @@ -69,27 +71,58 @@ struct fmt_spec int d; /* Number of implied decimal places. */ }; + +enum alignment + { + ALIGN_LEFT = 0, + ALIGN_RIGHT = 1, + ALIGN_CENTRE = 2 + }; + + +enum measure + { + MEASURE_NOMINAL=1, + MEASURE_ORDINAL=2, + MEASURE_SCALE=3 + }; + + + /* Descriptions of all the display formats above. */ extern struct fmt_desc formats[]; -/* Translates SPSS formats to PSPP formats. */ -extern const int translate_fmt[40]; - union value; -/* Maximum length of formatted value, in character. */ +/* Maximum length of formatted value, in characters. */ #define MAX_FORMATTED_LEN 256 -int parse_format_specifier (struct fmt_spec *input, int allow_xt); -int parse_format_specifier_name (const char **cp, int allow_xt); -int check_input_specifier (const struct fmt_spec *spec); -int check_output_specifier (const struct fmt_spec *spec); -int check_string_specifier (const struct fmt_spec *spec, int min_len); +/* Flags for parsing formats. */ +enum fmt_parse_flags + { + FMTP_ALLOW_XT = 001, /* 1=Allow X and T formats. */ + FMTP_SUPPRESS_ERRORS = 002 /* 1=Do not emit error messages. */ + }; + +/* Common formats. */ +extern const struct fmt_spec f8_2; /* F8.2. */ + +int parse_format_specifier (struct fmt_spec *input, enum fmt_parse_flags); +int parse_format_specifier_name (const char **cp, enum fmt_parse_flags); +int check_input_specifier (const struct fmt_spec *spec, int emit_error); +int check_output_specifier (const struct fmt_spec *spec, int emit_error); +bool check_specifier_type (const struct fmt_spec *, int type, bool emit_error); +bool check_specifier_width (const struct fmt_spec *, + int width, bool emit_error); void convert_fmt_ItoO (const struct fmt_spec *input, struct fmt_spec *output); +int get_format_var_width (const struct fmt_spec *); int parse_string_as_format (const char *s, int len, const struct fmt_spec *fp, int fc, union value *v); -void data_out (char *s, const struct fmt_spec *fp, const union value *v); +int translate_fmt (int spss); +bool data_out (char *s, const struct fmt_spec *fp, const union value *v); char *fmt_to_string (const struct fmt_spec *); void num_to_string (double v, char *s, int w, int d); +struct fmt_spec make_input_format (int type, int w, int d); +struct fmt_spec make_output_format (int type, int w, int d); #endif /* !format_h */