commit 37d55624dea3a6752fafa536d421c0e1fdee57ef
parent 0ab801c0986b526615a8868ee4a832c10c496d04
Author: conrad <conrad@9c49b5d1-7df3-0310-bce2-b7278e68f44c>
Date: Tue, 29 Apr 2008 23:47:28 +0000
use XGetAtomName instead of returning "<unknown atom>".
XGetAtomName result is copied to a static buffer and then freed.
Unneccesary check for utf8_atom!=XA_STRING**, and XSEL_DATA*** were removed.
** if utf8_atom == XA_STRING, than either atom == XA_STRING or not. If not,
the atom != utf8_atom and nothing happens. If it is, the previous comparison
of atom==XA_STRING would have made the function not arrive there at all.
*** XInternAtom with only_if_exists == True does a round-trip to the server
and back anyway. We might as well just use XGetAtomName.
Patch from Yair K.
git-svn-id: http://svn.kfish.org/xsel/trunk@247 9c49b5d1-7df3-0310-bce2-b7278e68f44c
Diffstat:
M | xsel.c | | | 19 | ++++++++++++++++--- |
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/xsel.c b/xsel.c
@@ -225,6 +225,9 @@ print_err (const char * fmt, ...)
static char *
get_atom_name (Atom atom)
{
+ char * ret;
+ static char atom_name[MAXLINE+1];
+
if (atom == None) return "None";
if (atom == XA_STRING) return "STRING";
if (atom == XA_PRIMARY) return "PRIMARY";
@@ -236,10 +239,20 @@ get_atom_name (Atom atom)
if (atom == incr_atom) return "INCR";
if (atom == null_atom) return "NULL";
if (atom == text_atom) return "TEXT";
- if (utf8_atom!=XA_STRING && atom == utf8_atom) return "UTF8_STRING";
- if (atom == XInternAtom (display, "XSEL_DATA", True)) return "XSEL_DATA";
+ if (atom == utf8_atom) return "UTF8_STRING";
+
+ ret = XGetAtomName (display, atom);
+ strncpy (atom_name, ret, sizeof (atom_name));
+ if (atom_name[MAXLINE] != '\0')
+ {
+ atom_name[MAXLINE-3] = '.';
+ atom_name[MAXLINE-2] = '.';
+ atom_name[MAXLINE-1] = '.';
+ atom_name[MAXLINE] = '\0';
+ }
+ XFree (ret);
- return "<unknown atom>";
+ return atom_name;
}
/*