| To: | austin-group-l@xxxxxxxxxxxxx |
|---|---|
| Subject: | [1003.1(2008)/Issue 7 0000177]: mismatch between example description and code |
| From: | Austin Group Bug Tracker <noreply@xxxxxxxxxxxxx> |
| Date: | Thu, 5 Nov 2009 21:44:04 +0000 |
| Keywords: | [1003.1(2008)/Issue 7] System Interfaces |
A NOTE has been added to this issue. ====================================================================== http://austingroupbugs.net/view.php?id=177 ====================================================================== Reported By: Don Cragun Assigned To: ajosey ====================================================================== Project: 1003.1(2008)/Issue 7 Issue ID: 177 Category: System Interfaces Type: Error Severity: Editorial Priority: normal Status: Under Review Name: Don Cragun Organization: N/A User Reference: strtok() example Section: strtok() Page Number: 2041 Line Number: 64700-64701 Interp Status: --- Final Accepted Text: ====================================================================== Date Submitted: 2009-11-03 22:32 UTC Last Modified: 2009-11-05 21:43 UTC ====================================================================== Summary: mismatch between example description and code ====================================================================== ---------------------------------------------------------------------- (0000286) SHwareSystems (reporter) - 2009-11-05 21:43 http://austingroupbugs.net/view.php?id=177#c286 ---------------------------------------------------------------------- dynamic allocation example of fgets(), per discussion: #include <limits.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> int f(FILE *fp) { long line_max; /* used to avoid multiple sysconf() calls */ char *line; /* the buffer */ /* declare other variables function needs */ /* get implementation instance's max expectable line length */ line_max = sysconf(_SC_LINE_MAX); /* account as practical for fgets() appending a NULL char */ if (line_max = LONG_MAX) return EOVERFLOW; line_max ++; line = malloc(line_max); /* get the buffer space */ if (line=NULL) return ENOMEM; /* error check required by malloc() */ /* set up other declared variables needed for the loop's processing */ while (fgets(line, line_max, fp) != NULL) { /* process returned full or partial line, accounting for there may be embedded NULL chars along with the appended one; assumes fgets result = line when non-NULL */ }; /* process possible fgets error values returned in errno and handle normal EOF condition */ free(line); /* clean up the dynamic memory usage */ return 0; /* function succeded */ } Issue History Date Modified Username Field Change ====================================================================== 2009-11-03 22:32 Don Cragun New Issue 2009-11-03 22:32 Don Cragun Status New => Under Review 2009-11-03 22:32 Don Cragun Assigned To => ajosey 2009-11-03 22:32 Don Cragun Name => Don Cragun 2009-11-03 22:32 Don Cragun Organization => N/A 2009-11-03 22:32 Don Cragun User Reference => strtok() example 2009-11-03 22:32 Don Cragun Section => strtok() 2009-11-03 22:32 Don Cragun Page Number => 2041 2009-11-03 22:32 Don Cragun Line Number => 64700-64701 2009-11-03 22:32 Don Cragun Interp Status => --- 2009-11-04 09:54 geoffclare Note Added: 0000277 2009-11-04 18:56 nick Note Added: 0000278 2009-11-05 21:43 SHwareSystems Note Added: 0000286 ====================================================================== |
| Previous by Date: | [Online Pubs 0000179]: POSIX 2008 word search looks in POSIX 2004, Austin Group Bug Tracker |
|---|---|
| Next by Date: | [1003.1(2008)/Issue 7 0000177]: mismatch between example description and code, Austin Group Bug Tracker |
| Previous by Thread: | [1003.1(2008)/Issue 7 0000177]: mismatch between example description and code, Austin Group Bug Tracker |
| Next by Thread: | [1003.1(2008)/Issue 7 0000177]: mismatch between example description and code, Austin Group Bug Tracker |
| Indexes: | [Date] [Thread] [All Lists] |