Commit f8bcc9ae authored by Seblu's avatar Seblu

now compile

parent 3cf69bc0
......@@ -6,7 +6,6 @@ DISTCLEANFILES=42sh$(EXEEXT)
.PHONY: tar doc re
42sh$(EXEEXT): src/42sh$(EXEEXT)
cp -f src/42sh$(EXEEXT) .
tar: distcheck
......
......@@ -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
SUBDIRS=ast builtin lexer parser
#SUBDIRS=
bin_PROGRAMS=42sh
#42sh_LDADD = parser/libparse.a ../check/leaktrack/libmem.a evalexpr/libevalexpr.a
......
......@@ -5,7 +5,7 @@
** Login <seblu@epita.fr>
**
** 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_ */
......@@ -5,35 +5,25 @@
** Login <seblu@epita.fr>
**
** 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 <stdlib.h>
#include "42sh.h"
#include "../var/var.h"
#include "../func/function.h"
#include "../history/history.h"
#include "../opt/opt.h"
#include <assert.h>
#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);
}
......@@ -5,7 +5,7 @@
** Login <seblu@epita.fr>
**
** 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 <stdio.h>
......@@ -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;
}
......@@ -5,7 +5,7 @@
** Login <seblu@epita.fr>
**
** 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 <stdlib.h>
......@@ -14,38 +14,35 @@
#include <stdio.h>
#include <sys/stat.h>
#include <stdlib.h>
#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; */
/* } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment