mirror of
https://github.com/file/file.git
synced 2024-11-23 18:05:31 +08:00
add a new member to hold the end-of-file offset instead of hijacking another
field to hold it.
This commit is contained in:
parent
2b04b43f92
commit
0c18beb601
@ -27,7 +27,7 @@
|
||||
*/
|
||||
/*
|
||||
* file.h - definitions for file(1) program
|
||||
* @(#)$File: file.h,v 1.188 2017/11/03 02:20:12 christos Exp $
|
||||
* @(#)$File: file.h,v 1.189 2017/11/03 14:28:54 christos Exp $
|
||||
*/
|
||||
|
||||
#ifndef __file_h__
|
||||
@ -402,7 +402,9 @@ struct magic_set {
|
||||
char *buf; /* Accumulation buffer */
|
||||
char *pbuf; /* Printable buffer */
|
||||
} o;
|
||||
uint32_t offset;
|
||||
uint32_t offset; /* a copy of m->offset while we */
|
||||
/* are working on the magic entry */
|
||||
uint32_t eoffset; /* offset from end of file */
|
||||
int error;
|
||||
int flags; /* Control magic tests. */
|
||||
int event_flags; /* Note things that happened. */
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "file.h"
|
||||
|
||||
#ifndef lint
|
||||
FILE_RCSID("@(#)$File: softmagic.c,v 1.253 2017/11/03 02:20:12 christos Exp $")
|
||||
FILE_RCSID("@(#)$File: softmagic.c,v 1.254 2017/11/03 14:28:54 christos Exp $")
|
||||
#endif /* lint */
|
||||
|
||||
#include "magic.h"
|
||||
@ -1367,10 +1367,7 @@ msetoffset(struct magic_set *ms, struct magic *m, struct buffer *bb,
|
||||
if ((size_t)-m->offset > b->elen)
|
||||
return -1;
|
||||
buffer_init(bb, -1, b->ebuf, bb->elen);
|
||||
ms->offset = b->elen + m->offset;
|
||||
// XXX: where to keep this info? not dangerous because
|
||||
// bb has always fd == -1
|
||||
bb->elen = ms->offset;
|
||||
ms->eoffset = ms->offset = b->elen + m->offset;
|
||||
} else {
|
||||
if (cont_level == 0) {
|
||||
// XXX: Pass real fd, then who frees bb?
|
||||
@ -1378,7 +1375,7 @@ msetoffset(struct magic_set *ms, struct magic *m, struct buffer *bb,
|
||||
ms->offset = m->offset;
|
||||
} else {
|
||||
if (bb->fbuf == b->ebuf)
|
||||
ms->offset = bb->elen + m->offset;
|
||||
ms->offset = ms->eoffset + m->offset;
|
||||
else
|
||||
ms->offset = m->offset;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user