Skip to content

Commit 1d7694e

Browse files
authored
Fix issue created by recent changes when PS was in A4 Landscape. (#8754)
Fixes #8753
1 parent ac1e654 commit 1d7694e

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/psconvert.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2045,14 +2045,14 @@ EXTERN_MSC int GMT_psconvert(void *V_API, int mode, void *args) {
20452045
char *psfile_to_use = NULL;
20462046
GMT_Report (API, GMT_MSG_INFORMATION, "Find HiResBoundingBox ...\n");
20472047
if (GMT->current.setting.run_mode == GMT_MODERN) /* Place BB file in session dir */
2048-
sprintf (BB_file, "%s/psconvert_%dc.bb", API->gwf_dir, (int)getpid());
2048+
sprintf(BB_file, "%s/psconvert_%dc.bb", API->gwf_dir, (int)getpid());
20492049
else
2050-
sprintf (BB_file, "%s/psconvert_%dc.bb", Ctrl->D.dir, (int)getpid());
2050+
sprintf(BB_file, "%s/psconvert_%dc.bb", Ctrl->D.dir, (int)getpid());
20512051
psfile_to_use = Ctrl->A.strip ? no_U_file : ((strlen (clean_PS_file) > 0) ? clean_PS_file : ps_file);
2052-
sprintf (cmd, "%s%s %s %s %c%s%c 2> %c%s%c",
2053-
at_sign, Ctrl->G.file, gs_BB, Ctrl->C.arg, quote, psfile_to_use, quote, quote, BB_file, quote);
2054-
GMT_Report (API, GMT_MSG_DEBUG, "Running: %s\n", cmd);
2055-
sys_retval = system (cmd); /* Execute the command that computes the tight BB */
2052+
sprintf(cmd, "%s%s %s %s %c%s%c 2> %c%s%c",
2053+
at_sign, Ctrl->G.file, gs_BB, Ctrl->C.arg, quote, psfile_to_use, quote, quote, BB_file, quote);
2054+
GMT_Report(API, GMT_MSG_DEBUG, "Running: %s\n", cmd);
2055+
sys_retval = system(cmd); /* Execute the command that computes the tight BB */
20562056
if (sys_retval) {
20572057
GMT_Report(API, GMT_MSG_ERROR, "System call [%s] returned error %d.\n", cmd, sys_retval);
20582058
fclose(fp);
@@ -2074,7 +2074,7 @@ EXTERN_MSC int GMT_psconvert(void *V_API, int mode, void *args) {
20742074
fp = fp2 = NULL;
20752075
if (gmt_truncate_file(API, ps_file, half_baked_size))
20762076
Return(GMT_RUNTIME_ERROR);
2077-
if (delete && gmt_remove_file (GMT, ps_file)) /* Since we created a temporary file from the memdata */
2077+
if (delete && gmt_remove_file(GMT, ps_file)) /* Since we created a temporary file from the memdata */
20782078
Return(GMT_RUNTIME_ERROR);
20792079
Return(GMT_ERROR_ON_FOPEN);
20802080
}
@@ -2199,20 +2199,21 @@ EXTERN_MSC int GMT_psconvert(void *V_API, int mode, void *args) {
21992199
else if ((strstr(line, "%%Creator:")) && !strncmp(&line[11], "GMT", 3))
22002200
isGMT_PS = true;
22012201
else if ((strstr(line, "%%Orientation:")) &&!strncmp(&line[15], "Landscape", 9)) {
2202+
landscape = landscape_orig = true;
22022203
if (Ctrl->O.active && (Ctrl->P.active || Ctrl->A.crop)) {
22032204
/* The case here is that the on a first time all wet well, but on a second run the Orientation
22042205
was still Landscape and later on the w(idth) and h(eight) were swapped because they are set
22052206
after value that were edit by the first run. The trick is then to set the Orientation to
22062207
Portrait even before the rotation had been applied.
22072208
*/
2208-
landscape = landscape_orig = true;
22092209
fseek(fp, (off_t)-(strlen(line)+1), SEEK_CUR); /* Seek back to start of line */
22102210
sprintf(line, "%%%%Orientation: Portrait \n");
22112211
fprintf(fp, "%s", line); fflush(fp);
22122212
}
22132213
}
22142214
else if ((strstr(line, "%%EndComments")))
22152215
got_end = true;
2216+
22162217
if (got_BBatend == 1 && (got_end || i == 19)) { /* Now is the time to look at the end of the file */
22172218
got_BBatend++; /* Avoid jumping more than once to the end */
22182219
if (file_processing) {

0 commit comments

Comments
 (0)