diff --git a/Makefile.am b/Makefile.am index 37232c57e43cbf93797b5eaa5140dca01201c2e5..ac37e92f1ed7b31a53a81edaa80aaf09f81e173c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6,7 +6,6 @@ DISTCLEANFILES=42sh$(EXEEXT) .PHONY: tar doc re 42sh$(EXEEXT): src/42sh$(EXEEXT) - cp -f src/42sh$(EXEEXT) . tar: distcheck diff --git a/configure.ac b/configure.ac index aeb412c95c74fc825a7057d8b1424b582ca67ad1..cc64d0b985443f7f580375414d9a1d89bc42c972 100644 --- a/configure.ac +++ b/configure.ac @@ -25,7 +25,7 @@ case $host_os in AC_SUBST([CFLAGS], ['-Wall -Werror -W -ansi -pedantic -D_XOPEN_SOURCE=600']) ;; *linux*) - AC_SUBST([CFLAGS], ['-Wall -Werror -W -ansi -pedantic -D_XOPEN_SOURCE=600']) + AC_SUBST([CFLAGS], ['-Wall -Werror -W -std=c99 -pedantic -D_XOPEN_SOURCE=600']) ;; *) pl="`uname -s`" @@ -66,7 +66,6 @@ AC_CHECK_FUNCS([getcwd]) AC_CHECK_FUNCS([setenv]) AC_CHECK_FUNCS([strdup]) AC_CHECK_FUNCS([strstr]) -AC_CHECK_FUNCS([get_current_dir_name]) AC_CHECK_FUNCS([atexit]) AC_CHECK_FUNCS([putenv]) AC_CHECK_FUNCS([strtoul]) @@ -106,15 +105,6 @@ AC_ARG_WITH([debug], ] ) -AC_ARG_WITH([leaktrack], - [AS_HELP_STRING([--with-leaktrack], [add a builtin leak track for debug])], - [ - if test x$withval = xyes; then - CFLAGS="$CFLAGS -DLEAK_TRACK" - fi - ], -) - AC_SUBST([CFLAGS]) # define Autoconf config header @@ -123,15 +113,7 @@ AC_CONFIG_HEADERS([config.h]) # define Autoconf config files AC_CONFIG_FILES([ Makefile - doc/Makefile - check/Makefile - check/leaktrack/Makefile src/Makefile - src/parser/Makefile - src/evalexpr/Makefile ]) -AC_CONFIG_FILES([check/checker_wrapper.sh], - [chmod a=rx check/checker_wrapper.sh]) - AC_OUTPUT diff --git a/src/Makefile.am b/src/Makefile.am index 1d3203c3865f4ead8467630022868796fe8ae188..3e3c2f3271c473ce472fdaa061798175ffff4120 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS=ast builtin lexer parser +#SUBDIRS= bin_PROGRAMS=42sh #42sh_LDADD = parser/libparse.a ../check/leaktrack/libmem.a evalexpr/libevalexpr.a diff --git a/src/shell/shell.h b/src/shell/shell.h index d125c3ef858330187d987489fa8df5c6bc27797a..b501530f649cff4ea88a6ef7a1634d8ea356f703 100644 --- a/src/shell/shell.h +++ b/src/shell/shell.h @@ -5,7 +5,7 @@ ** Login ** ** Started on Sun Jul 16 20:03:53 2006 Seblu -** Last update Sun Jul 16 20:12:27 2006 Seblu +** Last update Sun Jul 16 20:18:23 2006 Seblu */ #ifndef SHELL_H_ @@ -28,16 +28,16 @@ struct s_shell { - struct s_ast *ast; - struct s_var *vars; - struct s_func *funcs; - struct s_opt *opt; - struct s_history *history; +/* struct s_ast *ast; */ +/* struct s_var *vars; */ +/* struct s_func *funcs; */ +/* struct s_opt *opt; */ +/* struct s_history *history; */ int last_status; }; -struct s_shell *sh_init(void); -void sh_destroy(struct s_shell *sh); +struct s_shell *shell_init(void); +void shell_destroy(struct s_shell *sh); char *strmerges(int n, const char *s1, ...); #endif /* !SHELL_H_ */ diff --git a/src/shell/shell_destroy.c b/src/shell/shell_destroy.c index f35bdcacf4a24cf5f5055bdf2b4c1767f47b05da..33dbdc58b15410b6d08a16e879f14fae39bd6832 100644 --- a/src/shell/shell_destroy.c +++ b/src/shell/shell_destroy.c @@ -5,35 +5,25 @@ ** Login ** ** Started on Fri Apr 7 00:19:04 2006 Seblu -** Last update Sun May 21 15:29:07 2006 Seblu +** Last update Sun Jul 16 20:30:02 2006 Seblu */ #include -#include "42sh.h" -#include "../var/var.h" -#include "../func/function.h" -#include "../history/history.h" -#include "../opt/opt.h" +#include +#include "shell.h" -#include "mem.h" /*! ** Destroy 42SH structure. ** ** @param sh structure to destroy -** @note the sh = sh is needed if compile with -DNDEBUG since the assert will -** be suppressed. +** */ -void sh_destroy(struct s_42sh *sh) +void shell_destroy(struct s_shell *sh) { assert(sh); - if (opt_isset("readline", sh->opt) && sh->history) - { - history_save(sh); - history_delete(&sh->history); - } - var_delete(&sh->vars); - func_clean(&sh->funcs); - free(sh->opt); +/* var_delete(&sh->vars); */ +/* func_clean(&sh->funcs); */ +/* free(sh->opt); */ free(sh); } diff --git a/src/shell/shell_entry.c b/src/shell/shell_entry.c index 71f01bd2cd0970a963d38c5819f65287829038a0..6d6e44875bf65f7f8ba9b170f5656264c3864b06 100644 --- a/src/shell/shell_entry.c +++ b/src/shell/shell_entry.c @@ -5,7 +5,7 @@ ** Login ** ** Started on Mon Apr 10 23:57:28 2006 Seblu -** Last update Sun Jul 16 20:13:34 2006 Seblu +** Last update Sun Jul 16 20:26:30 2006 Seblu */ #include @@ -23,16 +23,22 @@ struct s_shell *shell = NULL; ** ** @return return program value */ + +#include "shell.h" + int main(int argc, char *argv[]) { int ret; - shell = sh_init(); - + /* shell initialization */ + shell = shell_init(); + /* parse arg line */ + argc = argc; + argv = argv; //open_parse(argc, argv, shell); -/* if (shell->ast) */ -/* exec_start(shell); */ + /* if (shell->ast) */ + /* exec_start(shell); */ ret = shell->last_status; - sh_destroy(shell); + shell_destroy(shell); return ret; } diff --git a/src/shell/shell_init.c b/src/shell/shell_init.c index af2941a29f8ba86395cb9aa7c88cd523edc505a7..745fd16eb1cf19188f5d411fb431e4054802bc08 100644 --- a/src/shell/shell_init.c +++ b/src/shell/shell_init.c @@ -5,7 +5,7 @@ ** Login ** ** Started on Sun Jul 16 20:11:09 2006 Seblu -** Last update Sun Jul 16 20:14:11 2006 Seblu +** Last update Sun Jul 16 20:27:58 2006 Seblu */ #include @@ -14,38 +14,35 @@ #include #include #include -#include "42sh.h" -#include "../var/var.h" -#include "../opt/opt.h" -#include "../history/history.h" +#include "shell.h" -static int pwd_isgood(); -static void set_default_option(struct s_opt *); + +/* static int pwd_isgood(); */ +/* static void set_default_option(struct s_opt *); */ /*! -** Create 42SH structure +** Create shell structure ** -** @return the new 42sh structure +** @return the new shell structure */ -struct s_shell *sh_init(void) +struct s_shell *shell_init(void) { - struct s_42sh *new; - char *tmp; + struct s_shell *new; +/* char *tmp; */ - secmalloc(new, sizeof (struct s_42sh)); - new->ast = NULL; - new->vars = var_create(); - new->funcs = NULL; - new->history = NULL; - secmalloc(new->opt, sizeof (struct s_opt)); - set_default_option(new->opt); - if (!pwd_isgood()) - { - var_setenv("PWD", (tmp = var_getcwd()), 1); - free(tmp); - } - var_unsetenv("OLDPWD"); - new->dot = 0; + secmalloc(new, sizeof (struct s_shell)); +/* new->ast = NULL; */ +/* new->vars = var_create(); */ +/* new->funcs = NULL; */ +/* new->history = NULL; */ +/* secmalloc(new->opt, sizeof (struct s_opt)); */ +/* set_default_option(new->opt); */ +/* if (!pwd_isgood()) */ +/* { */ +/* var_setenv("PWD", (tmp = var_getcwd()), 1); */ +/* free(tmp); */ +/* } */ +/* var_unsetenv("OLDPWD"); */ new->last_status = 0; return new; } @@ -54,38 +51,38 @@ struct s_shell *sh_init(void) ** Default sh option ** */ -static void set_default_option(struct s_opt *opt) -{ - opt_unset("xpg_echo", opt); - opt_unset("dotglob", opt); - opt_unset("extglob", opt); - opt_unset("nocaseglob", opt); - opt_unset("expand_aliases", opt); - opt_unset("bonus", opt); - opt_unset("readline", opt); -} +/* static void set_default_option(struct s_opt *opt) */ +/* { */ +/* opt_unset("xpg_echo", opt); */ +/* opt_unset("dotglob", opt); */ +/* opt_unset("extglob", opt); */ +/* opt_unset("nocaseglob", opt); */ +/* opt_unset("expand_aliases", opt); */ +/* opt_unset("bonus", opt); */ +/* opt_unset("readline", opt); */ +/* } */ /*! ** Check if pwd, if set on the current directory ** ** @return bool satus */ -static int pwd_isgood() -{ - char *pwd; - struct stat s_pwd; - ino_t ino_pwd; +/* static int pwd_isgood() */ +/* { */ +/* char *pwd; */ +/* struct stat s_pwd; */ +/* ino_t ino_pwd; */ - pwd = getenv("PWD"); - if (stat(pwd, &s_pwd) == -1) - return 0; - ino_pwd = s_pwd.st_ino; - pwd = var_getcwd(); - if (stat(pwd, &s_pwd) == -1) - { - perror("42sh"); - exit(1); - } - free(pwd); - return ino_pwd == s_pwd.st_ino; -} +/* pwd = getenv("PWD"); */ +/* if (stat(pwd, &s_pwd) == -1) */ +/* return 0; */ +/* ino_pwd = s_pwd.st_ino; */ +/* pwd = var_getcwd(); */ +/* if (stat(pwd, &s_pwd) == -1) */ +/* { */ +/* perror("42sh"); */ +/* exit(1); */ +/* } */ +/* free(pwd); */ +/* return ino_pwd == s_pwd.st_ino; */ +/* } */