Ruby 2.0.0p353(2013-11-22revision43784)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

stub.c
Go to the documentation of this file.
1 #include <ruby.h>
2 static void stub_sysinit(int *argc, char ***argv);
3 #define ruby_sysinit stub_sysinit
4 #include <main.c>
5 #undef ruby_sysinit
6
7 void
8 stub_sysinit(int *argc, char ***argv)
9 {
10 char exename[4096];
11 size_t lenexe, len0, lenall;
12 int i, ac;
13 char **av, *p;
14
15 lenexe = (size_t)GetModuleFileName(NULL, exename, sizeof exename);
16 ruby_sysinit(argc, argv);
17 ac = *argc;
18 av = *argv;
19 len0 = strlen(av[0]) + 1;
20 lenall = 0;
21 for (i = 1; i < ac; ++i) {
22 lenall += strlen(av[i]) + 1;
23 }
24 *argv = av = realloc(av, lenall + (lenexe + 1) * 2 + sizeof(char *) * (i + 2));
25 *argc = ++ac;
26 p = (char *)(av + i + 2);
27 memmove(p + (lenexe + 1) * 2, (char *)(av + ac) + len0, lenall);
28 memcpy(p, exename, lenexe);
29 p[lenexe] = '\0';
30 *av++ = p;
31 p += lenexe + 1;
32 memcpy(p, exename, lenexe);
33 p[lenexe] = '\0';
34 *av++ = p;
35 p += lenexe + 1;
36 while (--i) {
37 *av++ = p;
38 p += strlen(p) + 1;
39 }
40 *av = NULL;
41 }
42
main.c
strlen
size_t strlen(const char *)
p
Win32OLEIDispatch * p
Definition: win32ole.c:786
i
ssize_t i
Definition: bigdecimal.c:5655
memmove
RUBY_EXTERN void * memmove(void *, const void *, size_t)
Definition: memmove.c:7
ruby.h
realloc
void * realloc()
stub_sysinit
static void stub_sysinit(int *argc, char ***argv)
Definition: stub.c:8
argv
VALUE * argv
Definition: tcltklib.c:1971
memcpy
memcpy(buf+1, str, len)
ruby_sysinit
#define ruby_sysinit
Definition: stub.c:3
argc
int argc
Definition: tcltklib.c:1970
av
char ** av
Definition: tcltklib.c:8852
NULL
#define NULL
Definition: _sdbm.c:103