Lichen

Change of templates/native/system.c

921:8b6488daf7f6
templates/native/system.c
     1.1 --- a/templates/native/system.c	Tue Jun 22 23:03:52 2021 +0200
     1.2 +++ b/templates/native/system.c	Wed Jun 23 01:15:47 2021 +0200
     1.3 @@ -1,6 +1,6 @@
     1.4  /* Native functions for system operations.
     1.5  
     1.6 -Copyright (C) 2016, 2017 Paul Boddie <paul@boddie.org.uk>
     1.7 +Copyright (C) 2016, 2017, 2021 Paul Boddie <paul@boddie.org.uk>
     1.8  
     1.9  This program is free software; you can redistribute it and/or modify it under
    1.10  the terms of the GNU General Public License as published by the Free Software
    1.11 @@ -17,7 +17,9 @@
    1.12  */
    1.13  
    1.14  #include <stdlib.h> /* abs, exit */
    1.15 +#include <string.h> /* strlen */
    1.16  #include "types.h"
    1.17 +#include "common.h"
    1.18  #include "exceptions.h"
    1.19  #include "ops.h"
    1.20  #include "progconsts.h"
    1.21 @@ -27,6 +29,9 @@
    1.22  
    1.23  /* Environment support. */
    1.24  
    1.25 +extern int __argc;
    1.26 +extern char **__argv;
    1.27 +
    1.28  __attr __fn_native_system_exit(__attr __self, __attr status)
    1.29  {
    1.30      exit(__TOINT(status));
    1.31 @@ -35,8 +40,13 @@
    1.32  
    1.33  __attr __fn_native_system_get_argv(__attr __self)
    1.34  {
    1.35 -    /* NOTE: To be written. */
    1.36 -    return __builtins___none_None;
    1.37 +    __attr args[__argc];
    1.38 +    unsigned int i;
    1.39 +
    1.40 +    for (i = 0; i < __argc; i++)
    1.41 +        args[i] = __new_str(__argv[i], strlen(__argv[i]));
    1.42 +
    1.43 +    return __newdata_list(__argc, args);
    1.44  }
    1.45  
    1.46  __attr __fn_native_system_get_path(__attr __self)