Mercurial > octave
annotate libinterp/corefcn/getgrent.cc @ 19256:ce9bd5ed44d2 gui-release
usage of default suffix depending on filter in save as dialog (bug #43335)
* file-editor-tab.cc (save_file_as): use QStringList for adding filters,
initialize filter and default suffix depending on suffix of current file
name if available, connect the selection of a filter to a new slot;
(handle_save_as_filter_selected): new slot setting the default suffix
depending on the first suffix in selected filter;
* file-editor-tab.h: new slot handle_save_as_filter_selected
author | Torsten <ttl@justmail.de> |
---|---|
date | Thu, 16 Oct 2014 20:29:37 +0200 |
parents | 175b392e91fe |
children | 4197fc428c7d |
rev | line source |
---|---|
2928 | 1 /* |
2 | |
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
15195
diff
changeset
|
3 Copyright (C) 1996-2013 John W. Eaton |
2928 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
2928 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
2928 | 20 |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
27 #include <string> | |
28 | |
29 #include <sys/types.h> | |
30 | |
2937 | 31 #include "oct-group.h" |
2928 | 32 |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
33 #include "defun.h" |
2928 | 34 #include "error.h" |
35 #include "gripes.h" | |
36 #include "oct-map.h" | |
37 #include "ov.h" | |
38 #include "oct-obj.h" | |
39 #include "utils.h" | |
40 | |
41 // Group file functions. (Why not?) | |
42 | |
43 static octave_value | |
2937 | 44 mk_gr_map (const octave_group& gr) |
2928 | 45 { |
46 octave_value retval; | |
47 | |
48 if (gr) | |
49 { | |
11043
e9966851619b
getpwent.cc, getgrent.cc, getrusage.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
10182
diff
changeset
|
50 octave_scalar_map m; |
2928 | 51 |
4675 | 52 m.assign ("name", gr.name ()); |
53 m.assign ("passwd", gr.passwd ()); | |
54 m.assign ("gid", static_cast<double> (gr.gid ())); | |
55 m.assign ("mem", octave_value (gr.mem ())); | |
2928 | 56 |
57 retval = m; | |
58 } | |
59 else | |
4233 | 60 retval = 0; |
2928 | 61 |
62 return retval; | |
63 } | |
64 | |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
65 DEFUN (getgrent, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
66 "-*- texinfo -*-\n\ |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
67 @deftypefn {Built-in Function} {@var{grp_struct} =} getgrent ()\n\ |
3301 | 68 Return an entry from the group database, opening it if necessary.\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
69 Once the end of data has been reached, @code{getgrent} returns 0.\n\ |
3301 | 70 @end deftypefn") |
2928 | 71 { |
2937 | 72 octave_value_list retval; |
73 | |
3523 | 74 retval(1) = std::string (); |
4233 | 75 retval(0) = 0; |
2928 | 76 |
77 int nargin = args.length (); | |
78 | |
79 if (nargin == 0) | |
80 { | |
3523 | 81 std::string msg; |
2937 | 82 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
11553
diff
changeset
|
83 retval(1) = msg; |
2937 | 84 retval(0) = mk_gr_map (octave_group::getgrent (msg)); |
2928 | 85 } |
86 else | |
5823 | 87 print_usage (); |
2928 | 88 |
89 return retval; | |
90 } | |
91 | |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
92 DEFUN (getgrgid, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
93 "-*- texinfo -*-\n\ |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
94 @deftypefn {Built-in Function} {@var{grp_struct} =} getgrgid (@var{gid}).\n\ |
3301 | 95 Return the first entry from the group database with the group ID\n\ |
96 @var{gid}. If the group ID does not exist in the database,\n\ | |
97 @code{getgrgid} returns 0.\n\ | |
98 @end deftypefn") | |
2928 | 99 { |
2937 | 100 octave_value_list retval; |
101 | |
3523 | 102 retval(1) = std::string (); |
4233 | 103 retval(0) = 0; |
2928 | 104 |
105 int nargin = args.length (); | |
106 | |
107 if (nargin == 1) | |
108 { | |
109 double dval = args(0).double_value (); | |
110 | |
111 if (! error_state) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
112 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
113 if (D_NINT (dval) == dval) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
114 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
115 gid_t gid = static_cast<gid_t> (dval); |
2928 | 116 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
117 std::string msg; |
2937 | 118 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
11553
diff
changeset
|
119 retval(1) = msg; |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
120 retval(0) = mk_gr_map (octave_group::getgrgid (gid, msg)); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
121 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
122 else |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
123 error ("getgrgid: GID must be an integer"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
124 } |
2928 | 125 } |
126 else | |
5823 | 127 print_usage (); |
2928 | 128 |
129 return retval; | |
130 } | |
131 | |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
132 DEFUN (getgrnam, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
133 "-*- texinfo -*-\n\ |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
134 @deftypefn {Built-in Function} {@var{grp_struct} =} getgrnam (@var{name})\n\ |
3301 | 135 Return the first entry from the group database with the group name\n\ |
136 @var{name}. If the group name does not exist in the database,\n\ | |
9079
4d610aba7347
Cleanup documentation for system.texi, package.texi
Rik <rdrider0-list@yahoo.com>
parents:
7017
diff
changeset
|
137 @code{getgrnam} returns 0.\n\ |
3301 | 138 @end deftypefn") |
2928 | 139 { |
2937 | 140 octave_value_list retval; |
141 | |
3523 | 142 retval(1) = std::string (); |
4233 | 143 retval(0) = 0; |
2928 | 144 |
145 int nargin = args.length (); | |
146 | |
147 if (nargin == 1) | |
148 { | |
3523 | 149 std::string s = args(0).string_value (); |
2928 | 150 |
151 if (! error_state) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
152 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
153 std::string msg; |
2937 | 154 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
11553
diff
changeset
|
155 retval(1) = msg; |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
156 retval(0) = mk_gr_map (octave_group::getgrnam (s.c_str (), msg)); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9245
diff
changeset
|
157 } |
2928 | 158 } |
159 else | |
5823 | 160 print_usage (); |
2928 | 161 |
162 return retval; | |
163 } | |
164 | |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
165 DEFUN (setgrent, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
166 "-*- texinfo -*-\n\ |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
167 @deftypefn {Built-in Function} {} setgrent ()\n\ |
3301 | 168 Return the internal pointer to the beginning of the group database.\n\ |
169 @end deftypefn") | |
2928 | 170 { |
2937 | 171 octave_value_list retval; |
172 | |
3523 | 173 retval(1) = std::string (); |
2937 | 174 retval(0) = -1.0; |
2928 | 175 |
176 int nargin = args.length (); | |
177 | |
178 if (nargin == 0) | |
179 { | |
3523 | 180 std::string msg; |
2937 | 181 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
11553
diff
changeset
|
182 retval(1) = msg; |
2937 | 183 retval(0) = static_cast<double> (octave_group::setgrent (msg)); |
2928 | 184 } |
185 else | |
5823 | 186 print_usage (); |
2928 | 187 |
188 return retval; | |
189 } | |
190 | |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
191 DEFUN (endgrent, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
192 "-*- texinfo -*-\n\ |
15039
e753177cde93
maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents:
14138
diff
changeset
|
193 @deftypefn {Built-in Function} {} endgrent ()\n\ |
3301 | 194 Close the group database.\n\ |
195 @end deftypefn") | |
2928 | 196 { |
2937 | 197 octave_value_list retval; |
198 | |
3523 | 199 retval(1) = std::string (); |
2937 | 200 retval(0) = -1.0; |
2928 | 201 |
202 int nargin = args.length (); | |
203 | |
204 if (nargin == 0) | |
205 { | |
3523 | 206 std::string msg; |
2937 | 207 |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
11553
diff
changeset
|
208 retval(1) = msg; |
2937 | 209 retval(0) = static_cast<double> (octave_group::endgrent (msg)); |
2928 | 210 } |
211 else | |
5823 | 212 print_usage (); |
2928 | 213 |
214 return retval; | |
215 } |