X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Ftitle.c;h=7edd2dade7339f7cb881f3e3770bbc0bf9b3bd93;hb=053e7ff6e0a45a25d5604b211e9c950fff50e75d;hp=dca7b4760777b96e267808719b6dcf3930f41c38;hpb=3a7fba81ceae5b049d0f7d671e9e3c3c43bbf703;p=pspp diff --git a/src/title.c b/src/title.c index dca7b47607..7edd2dade7 100644 --- a/src/title.c +++ b/src/title.c @@ -14,15 +14,17 @@ 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. */ #include #include #include #include "alloc.h" #include "command.h" +#include "dictionary.h" #include "error.h" +#include "glob.h" #include "lexer.h" #include "main.h" #include "output.h" @@ -30,6 +32,9 @@ #include "version.h" #include "vfm.h" +#include "gettext.h" +#define _(msgid) gettext (msgid) + #include "debug-print.h" static int get_title (const char *cmd, char **title); @@ -60,7 +65,7 @@ get_title (const char *cmd, char **title) return CMD_FAILURE; if (*title) free (*title); - *title = xstrdup (ds_value (&tokstr)); + *title = xstrdup (ds_c_str (&tokstr)); lex_get (); if (token != '.') { @@ -75,6 +80,7 @@ get_title (const char *cmd, char **title) if (*title) free (*title); *title = xstrdup (lex_rest_of_line (NULL)); + lex_discard_line (); for (cp = *title; *cp; cp++) *cp = toupper ((unsigned char) (*cp)); token = '.'; @@ -87,9 +93,10 @@ get_title (const char *cmd, char **title) int cmd_file_label (void) { - char *label; + const char *label; label = lex_rest_of_line (NULL); + lex_discard_line (); while (isspace ((unsigned char) *label)) label++; @@ -114,7 +121,7 @@ add_document_line (const char *line, int indent) memcpy (new_documents, old_documents, old_len); memset (new_documents + old_len, ' ', indent); - st_bare_pad_copy (new_documents + old_len + indent, line, 80 - indent); + buf_copy_str_rpad (new_documents + old_len + indent, 80 - indent, line); new_documents[old_len + 80] = '\0'; dict_set_documents (default_dict, new_documents); @@ -129,34 +136,32 @@ cmd_document (void) /* Add a few header lines for reference. */ { char buf[256]; - struct tm *tmp = localtime (&last_vfm_invocation); if (dict_get_documents (default_dict) != NULL) add_document_line ("", 0); - sprintf (buf, _("Document entered %s %02d:%02d:%02d by %s (%s):"), - curdate, tmp->tm_hour, tmp->tm_min, tmp->tm_sec, version, - host_system); + sprintf (buf, _("Document entered %s by %s:"), get_start_date (), version); add_document_line (buf, 1); } for (;;) { int had_dot; - char *line; + const char *orig_line; + char *copy_line; - line = lex_rest_of_line (&had_dot); - while (isspace ((unsigned char) *line)) - line++; + orig_line = lex_rest_of_line (&had_dot); + lex_discard_line (); + while (isspace ((unsigned char) *orig_line)) + orig_line++; + copy_line = xmalloc (strlen (orig_line) + 2); + strcpy (copy_line, orig_line); if (had_dot) - { - char *cp = strchr (line, 0); - *cp++ = '.'; - *cp = 0; - } + strcat (copy_line, "."); - add_document_line (line, 3); + add_document_line (copy_line, 3); + free (copy_line); lex_get_line (); if (had_dot) @@ -171,9 +176,6 @@ cmd_document (void) int cmd_drop_documents (void) { - lex_match_id ("DROP"); - lex_match_id ("DOCUMENTS"); - dict_set_documents (default_dict, NULL); return lex_end_of_command ();