X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fprompt.c;h=614796e18e3dd3e79c2082d8966720bfe6a2376d;hb=afdf3096926b561f4e6511c10fcf73fc6796b9d2;hp=ede6a5e3b9c8c76d5b5d249113bc2537e3cff82d;hpb=e14e3990ef75795b40ee06a4b59a3e6af2d3aef0;p=pspp-builds.git diff --git a/src/language/prompt.c b/src/language/prompt.c index ede6a5e3..614796e1 100644 --- a/src/language/prompt.c +++ b/src/language/prompt.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2010 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2010, 2011 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 @@ -20,66 +20,43 @@ #include #include -#include "prompt.h" +#include "language/prompt.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "data/file-name.h" +#include "data/settings.h" +#include "data/variable.h" +#include "language/command.h" +#include "language/lexer/lexer.h" +#include "libpspp/assertion.h" +#include "libpspp/message.h" +#include "libpspp/str.h" +#include "libpspp/version.h" +#include "output/tab.h" -#include "xalloc.h" - -/* Current prompts in each style. */ -static char *prompts[PROMPT_CNT]; +#include "gl/xalloc.h" /* Current prompting style. */ static enum prompt_style current_style; -/* Initializes prompts. */ -void -prompt_init (void) -{ - prompts[PROMPT_FIRST] = xstrdup ("PSPP> "); - prompts[PROMPT_LATER] = xstrdup (" > "); - prompts[PROMPT_DATA] = xstrdup ("data> "); - current_style = PROMPT_FIRST; -} - -/* Frees prompts. */ -void -prompt_done (void) -{ - int i; - - for (i = 0; i < PROMPT_CNT; i++) - { - free (prompts[i]); - prompts[i] = NULL; - } -} - /* Gets the command prompt for the given STYLE. */ const char * prompt_get (enum prompt_style style) { - assert (style < PROMPT_CNT); - return prompts[style]; -} + switch (style) + { + case PROMPT_FIRST: + return "PSPP> "; -/* Sets the given STYLE's prompt to STRING. */ -void -prompt_set (enum prompt_style style, const char *string) -{ - assert (style < PROMPT_CNT); - free (prompts[style]); - prompts[style] = xstrdup (string); + case PROMPT_LATER: + return " > "; + + case PROMPT_DATA: + return "data> "; + + case PROMPT_CNT: + NOT_REACHED (); + } + NOT_REACHED (); } /* Sets STYLE as the current prompt style. */