annotate liboctave/lo-cutils.c @ 10544:9961fc022d9d

fix assignment to non-existing variables and octave_value::assign
author Jaroslav Hajek <highegg@gmail.com>
date Fri, 23 Apr 2010 11:23:43 +0200
parents 82db36545def
children aca961a3f387
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3613
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
1 /*
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
2
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
3 Copyright (C) 2000, 2001, 2002, 2003, 2005, 2006, 2007 John W. Eaton
3613
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
4
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
6
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6111
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6111
diff changeset
10 option) any later version.
3613
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
11
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
15 for more details.
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
16
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6111
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6111
diff changeset
19 <http://www.gnu.org/licenses/>.
3613
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
20
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
21 */
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
22
3803
63c75bc3db82 [project @ 2001-02-28 08:24:40 by jwe]
jwe
parents: 3786
diff changeset
23 /*
63c75bc3db82 [project @ 2001-02-28 08:24:40 by jwe]
jwe
parents: 3786
diff changeset
24
63c75bc3db82 [project @ 2001-02-28 08:24:40 by jwe]
jwe
parents: 3786
diff changeset
25 The function gethostname was adapted from a similar function from GNU
63c75bc3db82 [project @ 2001-02-28 08:24:40 by jwe]
jwe
parents: 3786
diff changeset
26 Bash, the Bourne Again SHell, copyright (C) 1987, 1989, 1991 Free
63c75bc3db82 [project @ 2001-02-28 08:24:40 by jwe]
jwe
parents: 3786
diff changeset
27 Software Foundation, Inc.
63c75bc3db82 [project @ 2001-02-28 08:24:40 by jwe]
jwe
parents: 3786
diff changeset
28
63c75bc3db82 [project @ 2001-02-28 08:24:40 by jwe]
jwe
parents: 3786
diff changeset
29 */
63c75bc3db82 [project @ 2001-02-28 08:24:40 by jwe]
jwe
parents: 3786
diff changeset
30
3613
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
31 #ifdef HAVE_CONFIG_H
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
32 #include <config.h>
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
33 #endif
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
34
4290
73431774c0b7 [project @ 2003-01-05 06:30:44 by jwe]
jwe
parents: 4093
diff changeset
35 /* This gives us a better chance of finding a prototype for strptime
73431774c0b7 [project @ 2003-01-05 06:30:44 by jwe]
jwe
parents: 4093
diff changeset
36 on some systems. */
73431774c0b7 [project @ 2003-01-05 06:30:44 by jwe]
jwe
parents: 4093
diff changeset
37
73431774c0b7 [project @ 2003-01-05 06:30:44 by jwe]
jwe
parents: 4093
diff changeset
38 #if ! defined (_XOPEN_SOURCE)
73431774c0b7 [project @ 2003-01-05 06:30:44 by jwe]
jwe
parents: 4093
diff changeset
39 #define _XOPEN_SOURCE
73431774c0b7 [project @ 2003-01-05 06:30:44 by jwe]
jwe
parents: 4093
diff changeset
40 #endif
73431774c0b7 [project @ 2003-01-05 06:30:44 by jwe]
jwe
parents: 4093
diff changeset
41
3803
63c75bc3db82 [project @ 2001-02-28 08:24:40 by jwe]
jwe
parents: 3786
diff changeset
42 #include <sys/types.h>
63c75bc3db82 [project @ 2001-02-28 08:24:40 by jwe]
jwe
parents: 3786
diff changeset
43 #include <unistd.h>
63c75bc3db82 [project @ 2001-02-28 08:24:40 by jwe]
jwe
parents: 3786
diff changeset
44
3613
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
45 #include <stdlib.h>
3803
63c75bc3db82 [project @ 2001-02-28 08:24:40 by jwe]
jwe
parents: 3786
diff changeset
46 #include <string.h>
3706
6581e686f83f [project @ 2000-07-25 05:30:02 by jwe]
jwe
parents: 3613
diff changeset
47 #include <time.h>
3613
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
48
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5451
diff changeset
49 #include "syswait.h"
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5451
diff changeset
50
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5453
diff changeset
51 OCTAVE_API void
3613
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
52 octave_qsort (void *base, size_t n, size_t size,
10180
be952ce74023 bootstrap.conf fixes
John W. Eaton <jwe@octave.org>
parents: 10178
diff changeset
53 int (*cmp) (const void *, const void *))
3613
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
54 {
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
55 qsort (base, n, size, cmp);
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
56 }
0a93682f89c8 [project @ 2000-03-17 10:58:25 by jwe]
jwe
parents:
diff changeset
57
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5453
diff changeset
58 OCTAVE_API int
6111
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents: 6108
diff changeset
59 octave_strcasecmp (const char *s1, const char *s2)
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents: 6108
diff changeset
60 {
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents: 6108
diff changeset
61 return strcasecmp (s1, s2);
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents: 6108
diff changeset
62 }
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents: 6108
diff changeset
63
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents: 6108
diff changeset
64 OCTAVE_API int
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents: 6108
diff changeset
65 octave_strncasecmp (const char *s1, const char *s2, size_t n)
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents: 6108
diff changeset
66 {
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents: 6108
diff changeset
67 return strncasecmp (s1, s2, n);
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents: 6108
diff changeset
68 }
ed81d74118bb [project @ 2006-10-27 02:43:23 by jwe]
jwe
parents: 6108
diff changeset
69
10174
eb64bf1c6107 use unlink module from gnulib
John W. Eaton <jwe@octave.org>
parents: 10173
diff changeset
70 OCTAVE_API int
3803
63c75bc3db82 [project @ 2001-02-28 08:24:40 by jwe]
jwe
parents: 3786
diff changeset
71 octave_gethostname (char *name, int namelen)
63c75bc3db82 [project @ 2001-02-28 08:24:40 by jwe]
jwe
parents: 3786
diff changeset
72 {
63c75bc3db82 [project @ 2001-02-28 08:24:40 by jwe]
jwe
parents: 3786
diff changeset
73 return gethostname (name, namelen);
63c75bc3db82 [project @ 2001-02-28 08:24:40 by jwe]
jwe
parents: 3786
diff changeset
74 }
3707
58140935c812 [project @ 2000-07-28 09:40:52 by jwe]
jwe
parents: 3706
diff changeset
75
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5307
diff changeset
76 #ifdef HAVE_LOADLIBRARY_API
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5307
diff changeset
77 #include <windows.h>
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5307
diff changeset
78
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5307
diff changeset
79 /* Need this since in C++ can't cast from int(*)() to void* */
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5453
diff changeset
80 OCTAVE_API void *
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5451
diff changeset
81 octave_w32_library_search (HINSTANCE handle, const char * name)
5451
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5307
diff changeset
82 {
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5307
diff changeset
83 return (GetProcAddress (handle, name));
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5307
diff changeset
84 }
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5307
diff changeset
85 #endif
ed08548b9054 [project @ 2005-09-15 19:52:50 by jwe]
jwe
parents: 5307
diff changeset
86
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5453
diff changeset
87 OCTAVE_API pid_t
5453
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5451
diff changeset
88 octave_waitpid (pid_t pid, int *status, int options)
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5451
diff changeset
89 {
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5451
diff changeset
90 return WAITPID (pid, status, options);
89f5979e8552 [project @ 2005-09-17 00:50:58 by jwe]
jwe
parents: 5451
diff changeset
91 }