From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,edafb2ab7e8839bc,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!i42g2000cwa.googlegroups.com!not-for-mail From: "KE" Newsgroups: comp.lang.ada Subject: Char type verification Date: 15 Nov 2006 14:00:33 -0800 Organization: http://groups.google.com Message-ID: <1163628033.606530.190550@i42g2000cwa.googlegroups.com> NNTP-Posting-Host: 88.240.56.59 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1163628039 9196 127.0.0.1 (15 Nov 2006 22:00:39 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 15 Nov 2006 22:00:39 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 1.0.3705; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: i42g2000cwa.googlegroups.com; posting-host=88.240.56.59; posting-account=SU8_Kw0AAABcLlEzcdMhoDhwaHkS8xUq Xref: g2news2.google.com comp.lang.ada:7477 Date: 2006-11-15T14:00:33-08:00 List-Id: Hi Assume that I have the following C code: #include #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.