Below is the list of changes that have just been committed into a local
4.1 repository of reggie. When reggie does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.2326 05/06/07 11:02:41 reggie@mdk10.(none) +1 -0
improved mapping from numerical open codes to string fopen codes.
This was necessary because the old code would return
"w+" for O_RDONLY|O_SHARE for example.
mysys/my_fopen.c
1.13 05/06/07 11:02:31 reggie@mdk10.(none) +41 -21
improved mapping from numerical open codes to string fopen codes.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: reggie
# Host: mdk10.(none)
# Root: /home/reggie/bk/41test3
--- 1.12/mysys/my_fopen.c 2005-05-25 04:56:41 -05:00
+++ 1.13/mysys/my_fopen.c 2005-06-07 11:02:31 -05:00
@@ -158,32 +158,52 @@
DBUG_RETURN(fd);
} /* my_fdopen */
+/*
+ make_ftype
+ Make a filehandler-open-typestring from ordinary inputflags
- /* Make a filehandler-open-typestring from ordinary inputflags */
-
+ Note: This routine attempts to find the best possible match
+ between a numeric option and a string option that could be
+ fed to fopen. There is not a 1 to 1 mapping between the two.
+
+ r == O_RDONLY
+ w == O_WRONLY|O_TRUNC|O_CREAT
+ a == O_WRONLY|O_APPEND|O_CREAT
+ r+ == O_RDWR
+ w+ == O_RDWR|O_TRUNC|O_CREAT
+ a+ == O_RDWR|O_APPEND|O_CREAT
+*/
static void make_ftype(register my_string to, register int flag)
{
-#if FILE_BINARY /* If we have binary-files */
+#if FILE_BINARY
+ /* If we have binary-files */
reg3 int org_flag=flag;
-#endif
- flag&= ~FILE_BINARY; /* remove binary bit */
- if (flag == O_RDONLY)
- *to++= 'r';
- else if (flag == O_WRONLY)
- *to++= 'w';
- else
- { /* Add '+' after theese */
- if (flag == O_RDWR)
+#endif
+ flag&= ~FILE_BINARY; /* remove binary bit */
+
+ /* check some possible invalid combinations */
+ DBUG_ASSERT(flag & (O_TRUNC|O_APPEND) != O_TRUNC|O_APPEND);
+
+ if (flag & (O_RDONLY|O_WRONLY) == O_WRONLY)
+ *to++= (flag & O_TRUNC) ? 'w' : 'a';
+ else if (flag & O_RDWR)
+ {
+ /* Add '+' after theese */
+ if (flag & O_TRUNC)
+ *to++= 'w';
+ else if (flag & O_APPEND)
+ *to++= 'a';
+ else
*to++= 'r';
- else if (flag & O_APPEND)
- *to++= 'a';
- else
- *to++= 'w'; /* Create file */
- *to++= '+';
- }
-#if FILE_BINARY /* If we have binary-files */
- if (org_flag & FILE_BINARY)
+ *to++= '+';
+ }
+ else
+ *to++= 'r';
+
+#if FILE_BINARY /* If we have binary-files */
+ if (org_flag & FILE_BINARY)
*to++='b';
-#endif
+#endif
*to='\0';
} /* make_ftype */
+
| Thread |
|---|
| • bk commit into 4.1 tree (reggie:1.2326) | reggie | 8 Jun |