Skip to content
Open
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
13 changes: 11 additions & 2 deletions post.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "post.h"

Expand Down Expand Up @@ -513,7 +514,7 @@ static void setpagesize(char *s)
return;
}
}
/* custom paper size in tenth of mm; example: 2100x2970 for a4 */
/* custom paper size in tenths of mm; example: 2100x2970 for a4. */
if (isdigit(s[0]) && strchr(s, 'x')) {
ps_pagewidth = atoi(s);
ps_pageheight = atoi(strchr(s, 'x') + 1);
Expand All @@ -534,13 +535,21 @@ static void setpagesize(char *s)
d1 = 9170;
d2 = 12970;
}


n = s[1] - '0';
ps_pagewidth = ((n & 1) ? d2 : d1) >> ((n + 1) >> 1);
ps_pageheight = ((n & 1) ? d1 : d2) >> (n >> 1);
ps_pagewidth -= ps_pagewidth % 10;
ps_pageheight -= ps_pageheight % 10;
}

static void setlandscape(void) {
int t = ps_pagewidth;
ps_pagewidth = ps_pageheight;
ps_pageheight = t;
}

void *mextend(void *old, long oldsz, long newsz, int memsz)
{
void *new = malloc(newsz * memsz);
Expand Down Expand Up @@ -659,5 +668,5 @@ int main(int argc, char *argv[])
free(name_desc);
free(name_page);
free(name_offset);
return 0;
return EXIT_SUCCESS;
}