1
0
mirror of synced 2026-04-13 23:53:51 +00:00

added pdf_compare_obj().

This commit is contained in:
Eric Smith
2003-03-07 11:02:31 +00:00
parent 55e3ee3787
commit 935c665c80
2 changed files with 38 additions and 2 deletions

View File

@@ -4,7 +4,7 @@
* will be compressed using ITU-T T.6 (G4) fax encoding.
*
* PDF routines
* $Id: pdf_prim.c,v 1.6 2003/03/04 17:58:36 eric Exp $
* $Id: pdf_prim.c,v 1.7 2003/03/07 03:02:31 eric Exp $
* Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -357,6 +357,38 @@ void pdf_set_real (struct pdf_obj *obj, double val)
}
int pdf_compare_obj (struct pdf_obj *o1, struct pdf_obj *o2)
{
if (o1->type == PT_IND_REF)
o1 = pdf_deref_ind_obj (o1);
if (o2->type == PT_IND_REF)
o2 = pdf_deref_ind_obj (o2);
pdf_assert (o1->type == o2->type);
switch (o1->type)
{
case PT_INTEGER:
if (o1->val.integer < o2->val.integer)
return (-1);
if (o1->val.integer > o2->val.integer)
return (1);
return (0);
case PT_REAL:
if (o1->val.real < o2->val.real)
return (-1);
if (o1->val.real > o2->val.real)
return (1);
return (0);
case PT_STRING:
return (strcmp (o1->val.string, o2->val.string));
default:
pdf_fatal ("invalid object type for comparison\n");
}
}
static int name_char_needs_quoting (char c)
{
return ((c < '!') || (c > '~') || (c == '/') || (c == '\\') ||

View File

@@ -4,7 +4,7 @@
* will be compressed using ITU-T T.6 (G4) fax encoding.
*
* PDF routines
* $Id: pdf_prim.h,v 1.5 2003/03/04 17:58:36 eric Exp $
* $Id: pdf_prim.h,v 1.6 2003/03/07 03:02:31 eric Exp $
* Copyright 2001, 2002, 2003 Eric Smith <eric@brouhaha.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -88,6 +88,10 @@ double pdf_get_real (struct pdf_obj *obj);
void pdf_set_real (struct pdf_obj *obj, double val);
/* returns -1 if o1 < 02, 0 if o1 == o2, 1 if o1 > o2 */
int pdf_compare_obj (struct pdf_obj *o1, struct pdf_obj *o2);
/* The callback will be called when the stream data is to be written to the
file. app_data will be passed as an argument to the callback. */
struct pdf_obj *pdf_new_stream (pdf_file_handle pdf_file,