comp.lang.ada
 help / color / mirror / Atom feed
* Char type verification
@ 2006-11-15 22:00 KE
  2006-11-15 21:57 ` Georg Bauhaus
                   ` (4 more replies)
  0 siblings, 5 replies; 34+ messages in thread
From: KE @ 2006-11-15 22:00 UTC (permalink / raw)


Hi

Assume that I have the following C code:

#include <stdio.h>

#define uchar   unsigned char


static uchar UCASE[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int _isupper(uchar c)
{
   return (c==UCASE[(c%'A')%26]);
}

int main(int argc, char *argv[])
{
    uchar c = (uchar) *argv[1];
    printf("_isupper('%c')? = %d\n",c,_isupper(c));

    return 0;
}

(I don't claim this is terribly safe, localizable, transparent, etc.
It's just practical within the confines of ASCII, and efficient since
it uses a table-lookup technique.)

Now, how would you convert this to Ada. As you can imagine, Ada
complains loudly with my fast and loose conversions of data types (char
to uchar, that to int, etc.)

(This is not some class assignment or anything. I'm a 40-something
coder new to Ada, and I'd like to see in how many different ways you
gentlemen will attempt to solve this.)

NB: The question's intent is, what would be the safest *and* the most
transparent way to marshall the details of this in Ada-95?

Thanks


K

P.S. Don't get bogged down with the printout details (using "printf"
and formatters, etc.). Just a plain output of the input character's
code and the result of the verification will do.




^ permalink raw reply	[flat|nested] 34+ messages in thread
* Re: Char type verification
@ 2006-11-16 16:01 Anh Vo
  0 siblings, 0 replies; 34+ messages in thread
From: Anh Vo @ 2006-11-16 16:01 UTC (permalink / raw)
  To: comp.lang.ada

It is not quite closed yet. You seem like a gentlemen with sharp knife
in the back. It is pleasure to exchange idea with the one who stays and
not worry about the one who left. Now, this thread is closed :-)

AV

>>> "KE" <koray.erkan@yahoo.com> 11/15/2006 11:02:57 PM >>>
I thank everyone for their posts. I consider this thread closed -- as
I've regretted posting it already.

I specifically thank Simon Wright and Steve Whalen for their civilized
attitude to help.

Special reward for being an utter smug jerk goes to Jeffrey Carter.

I believe I will not be bothering you or your newsgroup with any more
posts since most of you are obviously walking examples of perfection
and a gift to humanity. Ada is quite clearly not for an ordinary
mortal
like myself.




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

end of thread, other threads:[~2006-11-19  9:04 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-15 22:00 Char type verification KE
2006-11-15 21:57 ` Georg Bauhaus
2006-11-15 23:15   ` KE
2006-11-16  4:48     ` Jeffrey R. Carter
2006-11-16 19:53       ` Adam Beneschan
2006-11-16 23:30       ` Yves Bailly
2006-11-17  0:48         ` Jeffrey R. Carter
2006-11-17  1:59           ` Adam Beneschan
2006-11-17 11:30           ` Stephen Leake
2006-11-17 15:33             ` KE
2006-11-17 15:10               ` Georg Bauhaus
2006-11-17 18:30               ` Ludovic Brenta
2006-11-18  2:29                 ` Brian May
2006-11-17 19:45               ` Jeffrey R. Carter
     [not found]               ` <mQm7h.8782$ig4.3262@newsread2.news.pas.earthlink.net>
2006-11-17 19:56                 ` Jeffrey R. Carter
     [not found]                   ` <omz7h.222$1s6.165@newsread2.news.pas.earthlink.net>
2006-11-19  2:19                     ` OT: French Idioms (was Re: Char type verification) Jeffrey R. Carter
2006-11-19  9:04                       ` Dmitry A. Kazakov
2006-11-17 21:22         ` Char type verification Simon Wright
2006-11-17 23:59           ` Yves Bailly
2006-11-15 23:23 ` Simon Wright
2006-11-15 23:33   ` KE
2006-11-16  4:52     ` Jeffrey R. Carter
2006-11-15 23:36 ` Adam Beneschan
2006-11-15 23:55   ` KE
2006-11-16  4:54     ` Jeffrey R. Carter
2006-11-16  1:08 ` jimmaureenrogers
2006-11-16  1:45   ` KE
2006-11-16  2:15     ` jimmaureenrogers
2006-11-16  2:42     ` Steve Whalen
2006-11-16  9:36     ` Alex R. Mosteo
2006-11-16  7:02 ` KE
2006-11-16 17:04   ` Dmitry A. Kazakov
2006-11-16 22:43   ` Brian May
  -- strict thread matches above, loose matches on Subject: below --
2006-11-16 16:01 Anh Vo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox