Adopt use of gnulib for portability.
[pspp-builds.git] / src / include.c
index 78557bdd3777c07141369ee543a31a3c218af80f..abce511a0a74db2c3a8d57639f7dc9cad88d2107 100644 (file)
@@ -14,8 +14,8 @@
 
    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 <config.h>
 #include <ctype.h>
 #include "alloc.h"
 #include "command.h"
 #include "error.h"
-#include "getline.h"
+#include "getl.h"
 #include "lexer.h"
 #include "str.h"
 
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+
 int
-cmd_include_at (void)
+cmd_include (void)
 {
-  char *incfn, *s, *bp, *ep;
-
-  s = bp = lex_entire_line ();
-  while (isspace ((unsigned char) *bp))
-    bp++;
-  bp++;                                /* skip `@' */
-  while (isspace ((unsigned char) *bp))
-    bp++;
-  if (*bp == '\'')
-    bp++;
-
-  ep = bp + strlen (bp);
-  while (isspace ((unsigned char) *--ep));
-  if (*ep != '\'')
-    ep++;
+  /* Skip optional FILE=. */
+  if (lex_match_id ("FILE"))
+    lex_match ('=');
 
-  if (ep <= bp)
+  /* Filename can be identifier or string. */
+  if (token != T_ID && token != T_STRING) 
     {
-      msg (SE, _("Unrecognized filename format."));
+      lex_error (_("expecting filename")); 
       return CMD_FAILURE;
     }
-
-  /* Now the filename is trapped between bp and ep. */
-  incfn = xmalloc (ep - bp + 1);
-  strncpy (incfn, bp, ep - bp);
-  incfn[ep - bp] = 0;
-  getl_include (incfn);
-  free (incfn);
-
-  return CMD_SUCCESS;
-}
-
-int
-cmd_include (void)
-{
-  lex_get ();
-
-  if (!lex_force_string ())
-    return CMD_SUCCESS;
-  getl_include (ds_value (&tokstr));
+  getl_include (ds_c_str (&tokstr));
 
   lex_get ();
   return lex_end_of_command ();