projects
/
pspp-builds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
dict: Make dict_make_unique_var_name() return an allocated string.
[pspp-builds.git]
/
src
/
language
/
utilities
/
title.c
diff --git
a/src/language/utilities/title.c
b/src/language/utilities/title.c
index 982c626e091570f76bed81abfb8feb0215c4d939..82f7be50f5341b5b8cdddf69d0aba116dbafd302 100644
(file)
--- a/
src/language/utilities/title.c
+++ b/
src/language/utilities/title.c
@@
-1,5
+1,5
@@
/* PSPP - a program for statistical analysis.
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2007 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2007
, 2010
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-24,64
+24,57
@@
#include <data/variable.h>
#include <language/command.h>
#include <language/lexer/lexer.h>
#include <data/variable.h>
#include <language/command.h>
#include <language/lexer/lexer.h>
-#include <libpspp/alloc.h>
#include <libpspp/message.h>
#include <libpspp/start-date.h>
#include <libpspp/version.h>
#include <libpspp/message.h>
#include <libpspp/start-date.h>
#include <libpspp/version.h>
-#include <output/output.h>
+#include <output/text-item.h>
+
+#include "xalloc.h"
#include "gettext.h"
#define _(msgid) gettext (msgid)
#include "gettext.h"
#define _(msgid) gettext (msgid)
-static int get_title (struct lexer *, const char *cmd, char **title);
+static int parse_title (struct lexer *, enum text_item_type);
+static void set_title (const char *title, enum text_item_type);
int
cmd_title (struct lexer *lexer, struct dataset *ds UNUSED)
{
int
cmd_title (struct lexer *lexer, struct dataset *ds UNUSED)
{
- return
get_title (lexer, "TITLE", &outp_title
);
+ return
parse_title (lexer, TEXT_ITEM_TITLE
);
}
int
cmd_subtitle (struct lexer *lexer, struct dataset *ds UNUSED)
{
}
int
cmd_subtitle (struct lexer *lexer, struct dataset *ds UNUSED)
{
- return
get_title (lexer, "SUBTITLE", &outp_subtitle
);
+ return
parse_title (lexer, TEXT_ITEM_SUBTITLE
);
}
static int
}
static int
-
get_title (struct lexer *lexer, const char *cmd, char **titl
e)
+
parse_title (struct lexer *lexer, enum text_item_type typ
e)
{
{
- int c;
-
- c = lex_look_ahead (lexer);
- if (c == '"' || c == '\'')
+ if (lex_look_ahead (lexer) == T_STRING)
{
lex_get (lexer);
if (!lex_force_string (lexer))
return CMD_FAILURE;
{
lex_get (lexer);
if (!lex_force_string (lexer))
return CMD_FAILURE;
- if (*title)
- free (*title);
- *title = ds_xstrdup (lex_tokstr (lexer));
+ set_title (lex_tokcstr (lexer), type);
lex_get (lexer);
lex_get (lexer);
- if (lex_token (lexer) != '.')
- {
- msg (SE, _("%s: `.' expected after string."), cmd);
- return CMD_FAILURE;
- }
+ return lex_end_of_command (lexer);
}
else
{
}
else
{
- char *cp;
-
- if (*title)
- free (*title);
- *title = xstrdup (lex_rest_of_line (lexer));
+ set_title (lex_rest_of_line (lexer), type);
lex_discard_line (lexer);
lex_discard_line (lexer);
- for (cp = *title; *cp; cp++)
- *cp = toupper ((unsigned char) (*cp));
}
return CMD_SUCCESS;
}
}
return CMD_SUCCESS;
}
+static void
+set_title (const char *title, enum text_item_type type)
+{
+ text_item_submit (text_item_create (type, title));
+}
+
/* Performs the FILE LABEL command. */
int
cmd_file_label (struct lexer *lexer, struct dataset *ds)
/* Performs the FILE LABEL command. */
int
cmd_file_label (struct lexer *lexer, struct dataset *ds)
@@
-121,7
+114,7
@@
cmd_document (struct lexer *lexer, struct dataset *ds)
end_dot = lex_end_dot (lexer);
ds_assign_string (&line, lex_entire_line_ds (lexer));
if (end_dot)
end_dot = lex_end_dot (lexer);
ds_assign_string (&line, lex_entire_line_ds (lexer));
if (end_dot)
- ds_put_
char
(&line, '.');
+ ds_put_
byte
(&line, '.');
dict_add_document_line (dict, ds_cstr (&line));
lex_discard_line (lexer);
dict_add_document_line (dict, ds_cstr (&line));
lex_discard_line (lexer);
@@
-156,7
+149,7
@@
cmd_add_documents (struct lexer *lexer, struct dataset *ds)
while ( lex_is_string (lexer))
{
while ( lex_is_string (lexer))
{
- dict_add_document_line (dict,
ds_cstr (lex_tokstr (lexer)
));
+ dict_add_document_line (dict,
lex_tokcstr (lexer
));
lex_get (lexer);
}
lex_get (lexer);
}