From 599fb36a30fcd904100dfdc7d39e405b1746a64f Mon Sep 17 00:00:00 2001 From: Nicklas Larsson Date: Thu, 22 Dec 2022 15:24:38 +0100 Subject: [PATCH] apply .clang-format (#2715) --- doc/raster/r.example/main.c | 59 ++++++++++++++++++------------------- doc/vector/v.example/main.c | 33 +++++++++++---------- 2 files changed, 47 insertions(+), 45 deletions(-) diff --git a/doc/raster/r.example/main.c b/doc/raster/r.example/main.c index c7d2119fea8..43a940da9e4 100644 --- a/doc/raster/r.example/main.c +++ b/doc/raster/r.example/main.c @@ -1,4 +1,3 @@ - /**************************************************************************** * * MODULE: r.example @@ -10,8 +9,8 @@ * COPYRIGHT: (C) 2002, 2005-2009 by the GRASS Development Team * * This program is free software under the GNU General Public - * License (>=v2). Read the file COPYING that comes with GRASS - * for details. + * License (>=v2). Read the file COPYING that comes with GRASS + * for details. * *****************************************************************************/ @@ -22,15 +21,15 @@ #include #include -/* - * global function declaration +/* + * global function declaration */ extern CELL f_c(CELL); extern FCELL f_f(FCELL); extern DCELL f_d(DCELL); /* - * function definitions + * function definitions */ CELL c_calc(CELL x) @@ -58,25 +57,26 @@ DCELL d_calc(DCELL x) */ int main(int argc, char *argv[]) { - struct Cell_head cellhd; /* it stores region information, - and header information of rasters */ - char *name; /* input raster name */ - char *result; /* output raster name */ - char *mapset; /* mapset name */ - void *inrast; /* input buffer */ - unsigned char *outrast; /* output buffer */ + struct Cell_head cellhd; /* it stores region information, + and header information of rasters */ + char *name; /* input raster name */ + char *result; /* output raster name */ + char *mapset; /* mapset name */ + void *inrast; /* input buffer */ + unsigned char *outrast; /* output buffer */ int nrows, ncols; int row, col; - int infd, outfd; /* file descriptor */ - RASTER_MAP_TYPE data_type; /* type of the map (CELL/DCELL/...) */ - struct History history; /* holds meta-data (title, comments,..) */ + int infd, outfd; /* file descriptor */ + RASTER_MAP_TYPE data_type; /* type of the map (CELL/DCELL/...) */ + struct History history; /* holds meta-data (title, comments,..) */ - struct GModule *module; /* GRASS module for parsing arguments */ + struct GModule *module; /* GRASS module for parsing arguments */ - struct Option *input, *output; /* options */ + struct Option *input, *output; /* options */ /* initialize GIS environment */ - G_gisinit(argv[0]); /* reads grass env, stores program name to G_program_name() */ + G_gisinit( + argv[0]); /* reads grass env, stores program name to G_program_name() */ /* initialize module */ module = G_define_module(); @@ -98,7 +98,7 @@ int main(int argc, char *argv[]) name = input->answer; result = output->answer; - /* returns NULL if the map was not found in any mapset, + /* returns NULL if the map was not found in any mapset, * mapset name otherwise */ mapset = (char *)G_find_raster2(name, ""); if (mapset == NULL) @@ -142,19 +142,19 @@ int main(int argc, char *argv[]) /* use different function for each data type */ switch (data_type) { case CELL_TYPE: - c = ((CELL *) inrast)[col]; - c = c_calc(c); /* calculate */ - ((CELL *) outrast)[col] = c; + c = ((CELL *)inrast)[col]; + c = c_calc(c); /* calculate */ + ((CELL *)outrast)[col] = c; break; case FCELL_TYPE: - f = ((FCELL *) inrast)[col]; - f = f_calc(f); /* calculate */ - ((FCELL *) outrast)[col] = f; + f = ((FCELL *)inrast)[col]; + f = f_calc(f); /* calculate */ + ((FCELL *)outrast)[col] = f; break; case DCELL_TYPE: - d = ((DCELL *) inrast)[col]; - d = d_calc(d); /* calculate */ - ((DCELL *) outrast)[col] = d; + d = ((DCELL *)inrast)[col]; + d = d_calc(d); /* calculate */ + ((DCELL *)outrast)[col] = d; break; } } @@ -176,6 +176,5 @@ int main(int argc, char *argv[]) Rast_command_history(&history); Rast_write_history(result, &history); - exit(EXIT_SUCCESS); } diff --git a/doc/vector/v.example/main.c b/doc/vector/v.example/main.c index 97bfee5b2e0..68d0c5d45cc 100644 --- a/doc/vector/v.example/main.c +++ b/doc/vector/v.example/main.c @@ -1,4 +1,3 @@ - /**************************************************************** * * MODULE: v.example @@ -31,7 +30,7 @@ int main(int argc, char *argv[]) struct line_cats *Cats; int i, type, cat, ncols, nrows, col, more, open3d; char *mapset, sql[200]; - struct GModule *module; /* GRASS module for parsing arguments */ + struct GModule *module; /* GRASS module for parsing arguments */ struct Option *old, *new; dbDriver *driver; dbHandle handle; @@ -61,11 +60,13 @@ int main(int argc, char *argv[]) if (G_parser(argc, argv)) exit(EXIT_FAILURE); - /* Create and initialize struct's where to store points/lines and categories */ + /* Create and initialize struct's where to store + points/lines and categories + */ Points = Vect_new_line_struct(); Cats = Vect_new_cats_struct(); - /* Check 1) output is legal vector name; 2) if can find input map; + /* Check 1) output is legal vector name; 2) if can find input map; 3) if input was found in current mapset, check if input != output. lib/vector/Vlib/legal_vname.c */ @@ -74,7 +75,7 @@ int main(int argc, char *argv[]) if ((mapset = (char *)G_find_vector2(old->answer, "")) == NULL) G_fatal_error(_("Vector map <%s> not found"), old->answer); - /* Predetermine level at which a map will be opened for reading + /* Predetermine level at which a map will be opened for reading lib/vector/Vlib/open.c */ if (Vect_set_open_level(2)) @@ -109,13 +110,13 @@ int main(int argc, char *argv[]) G_fatal_error(_("Database connection not defined for layer %d"), 1); } - /* Output information useful for debuging + /* Output information useful for debuging include/vect/dig_structs.h */ G_debug(1, - "Field number:%d; Name:<%s>; Driver:<%s>; Database:<%s>; Table:<%s>; Key:<%s>;\n", - Fi->number, Fi->name, Fi->driver, Fi->database, Fi->table, - Fi->key); + "Field number:%d; Name:<%s>; Driver:<%s>; Database:<%s>; " + "Table:<%s>; Key:<%s>;\n", + Fi->number, Fi->name, Fi->driver, Fi->database, Fi->table, Fi->key); /* Prepeare strings for use in db_* calls */ db_init_string(&dbsql); @@ -170,8 +171,8 @@ int main(int argc, char *argv[]) G_debug(1, "SQL: \"%s\"", sql); db_set_string(&dbsql, sql); /* Now execute query */ - if (db_open_select_cursor(driver, &dbsql, &cursor, DB_SEQUENTIAL) - != DB_OK) + if (db_open_select_cursor(driver, &dbsql, &cursor, DB_SEQUENTIAL) != + DB_OK) G_warning(_("Unable to get attribute data for cat %d"), cat); else { /* Result count */ @@ -181,7 +182,8 @@ int main(int argc, char *argv[]) /* Let's output every columns name and value */ while (1) { if (db_fetch(&cursor, DB_NEXT, &more) != DB_OK) { - G_warning(_("Error while retrieving database record for cat %d"), + G_warning(_("Error while retrieving database record " + "for cat %d"), cat); break; } @@ -206,13 +208,14 @@ int main(int argc, char *argv[]) Fin = Vect_default_field_info(&Out, 1, NULL, GV_1TABLE); driver = db_start_driver_open_database(Fin->driver, Fin->database); G_debug(1, - "Field number:%d; Name:<%s>; Driver:<%s>; Database:<%s>; Table:<%s>; Key:<%s>;\n", + "Field number:%d; Name:<%s>; Driver:<%s>; Database:<%s>; " + "Table:<%s>; Key:<%s>;\n", Fin->number, Fin->name, Fin->driver, Fin->database, Fin->table, Fin->key); /* Let's copy attribute table data */ - if (db_copy_table(Fi->driver, Fi->database, Fi->table, - Fin->driver, Vect_subst_var(Fin->database, &Out), + if (db_copy_table(Fi->driver, Fi->database, Fi->table, Fin->driver, + Vect_subst_var(Fin->database, &Out), Fin->table) == DB_FAILED) G_warning(_("Unable to copy attribute table to vector map <%s>"), new->answer);