Skip to content

Commit 40b5982

Browse files
authored
Indent most of C code (#2544)
Indents most of the C and C++ code except for what is reported by indent as issues.
1 parent e817643 commit 40b5982

File tree

2,584 files changed

+226491
-221800
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,584 files changed

+226491
-221800
lines changed

db/db.columns/main.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ int main(int argc, char **argv)
4141
parse_command_line(argc, argv);
4242

4343
if (!db_table_exists(parms.driver, parms.database, parms.table)) {
44-
G_warning(_("Table <%s> not found in database <%s> using driver <%s>"),
45-
parms.table, parms.database, parms.driver);
46-
exit(EXIT_FAILURE);
44+
G_warning(_("Table <%s> not found in database <%s> using driver <%s>"),
45+
parms.table, parms.database, parms.driver);
46+
exit(EXIT_FAILURE);
4747
}
4848

4949
driver = db_start_driver(parms.driver);
5050
if (driver == NULL)
51-
G_fatal_error(_("Unable to start driver <%s>"), parms.driver);
51+
G_fatal_error(_("Unable to start driver <%s>"), parms.driver);
5252

5353
db_init_handle(&handle);
5454
db_set_handle(&handle, parms.database, NULL);
@@ -59,15 +59,15 @@ int main(int argc, char **argv)
5959
db_init_string(&table_name);
6060
db_set_string(&table_name, parms.table);
6161
if (db_describe_table(driver, &table_name, &table) != DB_OK)
62-
G_fatal_error(_("Unable to describe table <%s>"), parms.table);
62+
G_fatal_error(_("Unable to describe table <%s>"), parms.table);
6363

6464
db_close_database(driver);
6565
db_shutdown_driver(driver);
6666

6767
ncols = db_get_table_number_of_columns(table);
6868
for (col = 0; col < ncols; col++)
69-
fprintf(stdout, "%s\n",
70-
db_get_column_name(db_get_table_column(table, col)));
69+
fprintf(stdout, "%s\n",
70+
db_get_column_name(db_get_table_column(table, col)));
7171

7272
exit(EXIT_SUCCESS);
7373
}
@@ -88,11 +88,11 @@ static void parse_command_line(int argc, char **argv)
8888
driver = G_define_standard_option(G_OPT_DB_DRIVER);
8989
driver->options = db_list_drivers();
9090
if ((drv = db_get_default_driver_name()))
91-
driver->answer = (char *) drv;
91+
driver->answer = (char *)drv;
9292

9393
database = G_define_standard_option(G_OPT_DB_DATABASE);
9494
if ((db = db_get_default_database_name()))
95-
database->answer = (char *) db;
95+
database->answer = (char *)db;
9696

9797
/* Set description */
9898
module = G_define_module();
@@ -101,7 +101,7 @@ static void parse_command_line(int argc, char **argv)
101101
module->description = _("List all columns for a given table.");
102102

103103
if (G_parser(argc, argv))
104-
exit(EXIT_FAILURE);
104+
exit(EXIT_FAILURE);
105105

106106
parms.driver = driver->answer;
107107
parms.database = database->answer;

db/db.connect/main.c

+68-65
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ int main(int argc, char *argv[])
4444
G_add_keyword(_("attribute table"));
4545
G_add_keyword(_("connection settings"));
4646
module->description =
47-
_("Prints/sets general DB connection for current mapset.");
47+
_("Prints/sets general DB connection for current mapset.");
4848

4949
print = G_define_flag();
5050
print->key = 'p';
@@ -54,15 +54,16 @@ int main(int argc, char *argv[])
5454

5555
shell = G_define_flag();
5656
shell->key = 'g';
57-
shell->description = _("Print current connection parameters using shell style and exit");
57+
shell->description =
58+
_("Print current connection parameters using shell style and exit");
5859
shell->guisection = _("Print");
5960

6061
check_set_default = G_define_flag();
6162
check_set_default->key = 'c';
6263
check_set_default->description =
63-
_("Check connection parameters, set if uninitialized, and exit");
64+
_("Check connection parameters, set if uninitialized, and exit");
6465
check_set_default->guisection = _("Set");
65-
66+
6667
def = G_define_flag();
6768
def->key = 'd';
6869
def->label = _("Set from default settings and exit");
@@ -74,19 +75,20 @@ int main(int argc, char *argv[])
7475
driver = G_define_standard_option(G_OPT_DB_DRIVER);
7576
driver->options = db_list_drivers();
7677
if (strcmp(DB_DEFAULT_DRIVER, "sqlite") == 0) {
77-
driver->answer = "sqlite";
78+
driver->answer = "sqlite";
7879
}
7980
else {
80-
driver->answer = "dbf";
81+
driver->answer = "dbf";
8182
}
8283
driver->guisection = _("Set");
8384

8485
database = G_define_standard_option(G_OPT_DB_DATABASE);
8586
if (strcmp(DB_DEFAULT_DRIVER, "sqlite") == 0) {
86-
database->answer = "$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db";
87+
database->answer =
88+
"$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db";
8789
}
8890
else {
89-
database->answer = "$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/";
91+
database->answer = "$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/";
9092
}
9193
database->guisection = _("Set");
9294

@@ -99,7 +101,7 @@ int main(int argc, char *argv[])
99101
group->required = NO;
100102
group->multiple = NO;
101103
group->description = _("Default group of database users to which "
102-
"select privilege is granted");
104+
"select privilege is granted");
103105
group->guisection = _("Set");
104106

105107
/* commented due to new mechanism - see db.login
@@ -119,11 +121,11 @@ int main(int argc, char *argv[])
119121
*/
120122

121123
if (G_parser(argc, argv))
122-
exit(EXIT_FAILURE);
124+
exit(EXIT_FAILURE);
123125

124126
if (print->answer || shell->answer) {
125-
/* get and print connection in shell style */
126-
if (db_get_connection(&conn) == DB_OK) {
127+
/* get and print connection in shell style */
128+
if (db_get_connection(&conn) == DB_OK) {
127129
if (shell->answer) {
128130
fprintf(stdout, "driver=%s\n",
129131
conn.driverName ? conn.driverName : "");
@@ -135,121 +137,121 @@ int main(int argc, char *argv[])
135137
}
136138
else {
137139
databaseName = substitute_variables(&conn);
138-
140+
139141
fprintf(stdout, "driver: %s\n",
140142
conn.driverName ? conn.driverName : "");
141143
/* substitute variables */
142144
fprintf(stdout, "database: %s\n", databaseName);
143145
G_free(database);
144-
146+
145147
fprintf(stdout, "schema: %s\n",
146148
conn.schemaName ? conn.schemaName : "");
147149
fprintf(stdout, "group: %s\n", conn.group ? conn.group : "");
148150
}
149151
}
150-
else
151-
G_fatal_error(_("Database connection not defined. "
152-
"Run db.connect."));
153-
154-
exit(EXIT_SUCCESS);
152+
else
153+
G_fatal_error(_("Database connection not defined. "
154+
"Run db.connect."));
155+
156+
exit(EXIT_SUCCESS);
155157
}
156-
158+
157159
if (check_set_default->answer) {
158-
/* check connection and set to system-wide default in required */
159-
/*
160-
* TODO: improve db_{get,set}_connection() to not return DB_OK on error
161-
* (thus currently there is no point in checking for that here)
162-
*/
163-
db_get_connection(&conn);
160+
/* check connection and set to system-wide default in required */
161+
/*
162+
* TODO: improve db_{get,set}_connection() to not return DB_OK on error
163+
* (thus currently there is no point in checking for that here)
164+
*/
165+
db_get_connection(&conn);
164166

165-
if (!conn.driverName && !conn.databaseName) {
167+
if (!conn.driverName && !conn.databaseName) {
166168

167-
db_set_default_connection();
168-
db_get_connection(&conn);
169+
db_set_default_connection();
170+
db_get_connection(&conn);
169171

170172
databaseName = substitute_variables(&conn);
171-
G_important_message(_("Default driver / database set to:\n"
172-
"driver: %s\ndatabase: %s"), conn.driverName,
173-
databaseName);
174-
}
173+
G_important_message(_("Default driver / database set to:\n"
174+
"driver: %s\ndatabase: %s"),
175+
conn.driverName, databaseName);
176+
}
175177
else {
176178
G_important_message(_("DB settings already defined, nothing to do"));
177179
}
178-
179-
/* they must be a matched pair, so if one is set but not the other
180-
then give up and let the user figure it out */
181-
if (!conn.driverName) {
182-
G_fatal_error(_("Default driver is not set"));
183-
}
184-
if (!conn.databaseName) {
185-
G_fatal_error(_("Default database is not set"));
186-
}
187-
188-
/* connection either already existed or now exists */
189-
exit(EXIT_SUCCESS);
180+
181+
/* they must be a matched pair, so if one is set but not the other
182+
then give up and let the user figure it out */
183+
if (!conn.driverName) {
184+
G_fatal_error(_("Default driver is not set"));
185+
}
186+
if (!conn.databaseName) {
187+
G_fatal_error(_("Default database is not set"));
188+
}
189+
190+
/* connection either already existed or now exists */
191+
exit(EXIT_SUCCESS);
190192
}
191193

192194
if (def->answer) {
193-
db_set_default_connection();
194-
db_get_connection(&conn);
195-
195+
db_set_default_connection();
196+
db_get_connection(&conn);
197+
196198
databaseName = substitute_variables(&conn);
197-
G_important_message(_("Default driver / database set to:\n"
198-
"driver: %s\ndatabase: %s"), conn.driverName,
199-
databaseName);
200-
exit(EXIT_SUCCESS);
199+
G_important_message(_("Default driver / database set to:\n"
200+
"driver: %s\ndatabase: %s"), conn.driverName,
201+
databaseName);
202+
exit(EXIT_SUCCESS);
201203
}
202-
204+
203205
/* do not read current, set new connection from options */
204206
G_zero(&conn, sizeof(dbConnection));
205207

206208
if (driver->answer)
207-
conn.driverName = driver->answer;
209+
conn.driverName = driver->answer;
208210

209211
if (database->answer)
210-
conn.databaseName = database->answer;
212+
conn.databaseName = database->answer;
211213

212214
if (schema->answer)
213-
conn.schemaName = schema->answer;
215+
conn.schemaName = schema->answer;
214216

215217
if (group->answer)
216-
conn.group = group->answer;
218+
conn.group = group->answer;
217219

218220
db_set_connection(&conn);
219221
/* check */
220222
if (db_get_connection(&conn) != DB_OK) {
221-
G_fatal_error(_("Unable to set default database connection"));
223+
G_fatal_error(_("Unable to set default database connection"));
222224

223-
exit(EXIT_FAILURE);
225+
exit(EXIT_FAILURE);
224226
}
225227

226228
exit(EXIT_SUCCESS);
227229
}
228230

229-
char *substitute_variables(dbConnection *conn)
231+
char *substitute_variables(dbConnection * conn)
230232
{
231233
char *database, *c, buf[GPATH_MAX];
232234

233235
if (!conn->databaseName)
234236
return NULL;
235237

236-
database = (char *) G_malloc(GPATH_MAX);
238+
database = (char *)G_malloc(GPATH_MAX);
237239
strcpy(database, conn->databaseName);
238-
240+
239241
strcpy(buf, database);
240242
c = (char *)strstr(buf, "$GISDBASE");
241243
if (c != NULL) {
242244
*c = '\0';
243245
sprintf(database, "%s%s%s", buf, G_gisdbase(), c + 9);
244246
}
245-
247+
246248
strcpy(buf, database);
247249
c = (char *)strstr(buf, "$LOCATION_NAME");
248250
if (c != NULL) {
249251
*c = '\0';
250252
sprintf(database, "%s%s%s", buf, G_location(), c + 14);
251253
}
252-
254+
253255
strcpy(buf, database);
254256
c = (char *)strstr(buf, "$MAPSET");
255257
if (c != NULL) {
@@ -260,8 +262,9 @@ char *substitute_variables(dbConnection *conn)
260262
if (strcmp(conn->driverName, "sqlite") == 0 ||
261263
strcmp(conn->driverName, "dbf") == 0) {
262264
char *p;
265+
263266
p = database;
264-
while(*p) {
267+
while (*p) {
265268
if (*p == '/')
266269
*p = HOST_DIRSEP;
267270
p++;

0 commit comments

Comments
 (0)