Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions include/grass/defs/raster.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,8 @@ int Rast_option_to_interp_type(const struct Option *);
/* mask_info.c */
char *Rast_mask_info(void);
char *Rast_mask_name(void);
bool Rast_mask_status(char *, char *, bool *, char *, char *);
bool Rast_mask_status(char *, char *, bool *, char[GNAME_MAX],
char[GMAPSET_MAX]);
int Rast__mask_info(char *, char *);
bool Rast_mask_is_present(void);
int Rast_disable_omp_on_mask(int);
Expand Down Expand Up @@ -558,7 +559,8 @@ bool Rast_legal_semantic_label(const char *);
int Rast_map_to_img_str(char *, int, unsigned char *);

/* reclass.c */
int Rast_is_reclass(const char *, const char *, char *, char *);
int Rast_is_reclass(const char *, const char *, char[GNAME_MAX],
char[GMAPSET_MAX]);
int Rast_is_reclassed_to(const char *, const char *, int *, char ***);
int Rast_get_reclass(const char *, const char *, struct Reclass *);
void Rast_free_reclass(struct Reclass *);
Expand Down
3 changes: 2 additions & 1 deletion lib/raster/mask_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ static bool Rast__get_present_mask(char *name, char *mapset)
* @return true if mask is present, false otherwise
*/
bool Rast_mask_status(char *name, char *mapset, bool *is_mask_reclass,
char *reclass_name, char *reclass_mapset)
char reclass_name[GNAME_MAX],
char reclass_mapset[GMAPSET_MAX])
{
bool present = Rast__get_present_mask(name, mapset);

Expand Down
28 changes: 12 additions & 16 deletions lib/raster/reclass.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ static int get_reclass_table(FILE *, struct Reclass *);
* \return 0 if it is not
* \return -1 if there was a problem reading the raster header
*/
int Rast_is_reclass(const char *name, const char *mapset, char *rname,
char *rmapset)
int Rast_is_reclass(const char *name, const char *mapset, char rname[GNAME_MAX],
char rmapset[GMAPSET_MAX])
{
FILE *fd;
int type;
Expand Down Expand Up @@ -142,13 +142,15 @@ int Rast_get_reclass(const char *name, const char *mapset,
{
FILE *fd;
int stat;
char rname[GNAME_MAX] = {0}, rmapset[GMAPSET_MAX] = {0};
char *tmp_name = rname, *tmp_mapset = rmapset;

fd = fopen_cellhd_old(name, mapset);
if (fd == NULL)
return -1;
reclass->name = NULL;
reclass->mapset = NULL;
reclass->type = reclass_type(fd, &reclass->name, &reclass->mapset);
reclass->type = reclass_type(fd, &tmp_name, &tmp_mapset);
reclass->name = G_store(tmp_name);
reclass->mapset = G_store(tmp_mapset);
if (reclass->type <= 0) {
fclose(fd);
return reclass->type;
Expand Down Expand Up @@ -224,22 +226,16 @@ static int reclass_type(FILE *fd, char **rname, char **rmapset)
return -1;
if (sscanf(buf, "%[^:]:%s", label, arg) != 2)
return -1;
if (strncmp(label, "maps", 4) == 0) {
if (*rmapset)
strcpy(*rmapset, arg);
else
*rmapset = G_store(arg);
if (strncmp(label, "maps", 4) == 0 && *rmapset) {
G_strlcpy(*rmapset, arg, GMAPSET_MAX);
}
else if (strncmp(label, "name", 4) == 0) {
if (*rname)
strcpy(*rname, arg);
else
*rname = G_store(arg);
else if (strncmp(label, "name", 4) == 0 && *rname) {
G_strlcpy(*rname, arg, GNAME_MAX);
}
else
return -1;
}
if (**rmapset && **rname)
if ((*rmapset && **rmapset) || (*rname && **rname))
return type;
else
return -1;
Expand Down
Loading