tech@mandoc.bsd.lv
 help / color / mirror / Atom feed
* MACHINE not defined and a few cast nits
@ 2015-01-18  9:14 Kristaps Dzonsons
  2015-01-22  0:20 ` Ingo Schwarze
  0 siblings, 1 reply; 2+ messages in thread
From: Kristaps Dzonsons @ 2015-01-18  9:14 UTC (permalink / raw)
  To: tech

[-- Attachment #1: Type: text/plain, Size: 312 bytes --]

Enclosed is a patch for compilation on Mac OS X.  If wraps the MACHINE 
in #ifdef, but I'm not sure how to get this without invoking sysctl(3) 
for each and every invocation of mandoc.  Which won't work on windows 
anyway, I reckon.

I also cast some unsigned char's that clang complains about.

Best,

Kristaps

[-- Attachment #2: machine.diff --]
[-- Type: text/plain, Size: 1434 bytes --]

? .DS_Store
? Makefile.local
? cgi.h
? config.h
? config.log
? configure.local
? demandoc
? machine.diff
? mandoc
Index: main.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/main.c,v
retrieving revision 1.216
diff -u -p -r1.216 main.c
--- main.c	16 Jan 2015 21:15:05 -0000	1.216
+++ main.c	18 Jan 2015 09:14:40 -0000
@@ -321,18 +321,20 @@ main(int argc, char *argv[])
 				argc = 1;
 			}
 		} else if (argc > 1 &&
-		    ((uc = argv[0]) != NULL) &&
+		    ((uc = (unsigned char *)argv[0]) != NULL) &&
 		    ((isdigit(uc[0]) && (uc[1] == '\0' ||
 		      (isalpha(uc[1]) && uc[2] == '\0'))) ||
 		     (uc[0] == 'n' && uc[1] == '\0'))) {
-			search.sec = uc;
+			search.sec = (char *)uc;
 			argv++;
 			argc--;
 		}
 		if (search.arch == NULL)
 			search.arch = getenv("MACHINE");
+#ifdef MACHINE
 		if (search.arch == NULL)
 			search.arch = MACHINE;
+#endif
 	}
 
 	rc = MANDOCLEVEL_OK;
Index: preconv.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/preconv.c,v
retrieving revision 1.13
diff -u -p -r1.13 preconv.c
--- preconv.c	19 Dec 2014 04:58:35 -0000	1.13
+++ preconv.c	18 Jan 2015 09:14:40 -0000
@@ -33,7 +33,7 @@ preconv_encode(struct buf *ib, size_t *i
 	int		 nby;
 	unsigned int	 accum;
 
-	cu = ib->buf + *ii;
+	cu = (unsigned char *)ib->buf + *ii;
 	assert(*cu & 0x80);
 
 	if ( ! (*filenc & MPARSE_UTF8))

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: MACHINE not defined and a few cast nits
  2015-01-18  9:14 MACHINE not defined and a few cast nits Kristaps Dzonsons
@ 2015-01-22  0:20 ` Ingo Schwarze
  0 siblings, 0 replies; 2+ messages in thread
From: Ingo Schwarze @ 2015-01-22  0:20 UTC (permalink / raw)
  To: Kristaps Dzonsons; +Cc: tech

Hi Kristaps,

Kristaps Dzonsons wrote on Sun, Jan 18, 2015 at 10:14:54AM +0100:

> Enclosed is a patch for compilation on Mac OS X.  If wraps the
> MACHINE in #ifdef, but I'm not sure how to get this without invoking
> sysctl(3) for each and every invocation of mandoc.  Which won't work
> on windows anyway, I reckon.
> 
> I also cast some unsigned char's that clang complains about.

OK schwarze@ for the whole patch.

I agree that the #ifdef makes sense.  I already worried that this
might blow up on some platforms, but didn't realize it can be
fixed so elegantly.  Using sysctl(3) indeed looks like overkill.
This ought to be done at compile or configure time, not at run time.

Should i add support for setting MACHINE from configure.local
after your commit has gone in?

Yours,
  Ingo


> Index: main.c
> ===================================================================
> RCS file: /home/cvs/mdocml/mdocml/main.c,v
> retrieving revision 1.216
> diff -u -p -r1.216 main.c
> --- main.c	16 Jan 2015 21:15:05 -0000	1.216
> +++ main.c	18 Jan 2015 09:14:40 -0000
> @@ -321,18 +321,20 @@ main(int argc, char *argv[])
>  				argc = 1;
>  			}
>  		} else if (argc > 1 &&
> -		    ((uc = argv[0]) != NULL) &&
> +		    ((uc = (unsigned char *)argv[0]) != NULL) &&
>  		    ((isdigit(uc[0]) && (uc[1] == '\0' ||
>  		      (isalpha(uc[1]) && uc[2] == '\0'))) ||
>  		     (uc[0] == 'n' && uc[1] == '\0'))) {
> -			search.sec = uc;
> +			search.sec = (char *)uc;
>  			argv++;
>  			argc--;
>  		}
>  		if (search.arch == NULL)
>  			search.arch = getenv("MACHINE");
> +#ifdef MACHINE
>  		if (search.arch == NULL)
>  			search.arch = MACHINE;
> +#endif
>  	}
>  
>  	rc = MANDOCLEVEL_OK;
> Index: preconv.c
> ===================================================================
> RCS file: /home/cvs/mdocml/mdocml/preconv.c,v
> retrieving revision 1.13
> diff -u -p -r1.13 preconv.c
> --- preconv.c	19 Dec 2014 04:58:35 -0000	1.13
> +++ preconv.c	18 Jan 2015 09:14:40 -0000
> @@ -33,7 +33,7 @@ preconv_encode(struct buf *ib, size_t *i
>  	int		 nby;
>  	unsigned int	 accum;
>  
> -	cu = ib->buf + *ii;
> +	cu = (unsigned char *)ib->buf + *ii;
>  	assert(*cu & 0x80);
>  
>  	if ( ! (*filenc & MPARSE_UTF8))
--
 To unsubscribe send an email to tech+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-01-22  0:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-18  9:14 MACHINE not defined and a few cast nits Kristaps Dzonsons
2015-01-22  0:20 ` Ingo Schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).