# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: mhameed@src.gnome.org-20110629161905-zt9o9qkb2gpo9c10
# target_branch: http://bzr.nvaccess.org/nvda/main/
# testament_sha1: 3cb2a601f4077d81702617582918318976eef4d1
# timestamp: 2011-06-29 17:19:57 +0100
# base_revision_id: mick@kulgan.net-20110629041017-m73oy4rzptq9ls33
# 
# Begin patch
=== modified file 'source/textInfos/offsets.py'
--- source/textInfos/offsets.py	2011-06-22 06:40:12 +0000
+++ source/textInfos/offsets.py	2011-06-29 16:19:05 +0000
@@ -5,6 +5,7 @@
 #Copyright (C) 2006 Michael Curran <mick@kulgan.net>, James Teh <jamie@jantrid.net>
 
 import re
+import string
 import ctypes
 import NVDAHelper
 import textInfos
@@ -99,10 +100,10 @@
 		return offset
 	while offset>0 and text[offset].isspace():
 		offset-=1
-	if not text[offset].isalnum():
+	if text[offset].isspace() or text[offset] in string.punctuation:
 		return offset
 	else:
-		while offset>0 and text[offset-1].isalnum():
+		while offset>0 and not (text[offset-1].isspace() or text[offset] in string.punctuation):
 			offset-=1
 	return offset
 
@@ -119,11 +120,9 @@
 """
 	if offset>=len(text):
 		return offset+1
-	if text[offset].isalnum():
-		while offset<len(text) and text[offset].isalnum():
+	if not (text[offset].isspace() or text[offset] in string.punctuation):
+		while offset<len(text) and not (text[offset].isspace() or text[offset] in string.punctuation):
 			offset+=1
-	elif not text[offset].isspace() and not text[offset].isalnum():
-		offset+=1
 	while offset<len(text) and text[offset].isspace():
 		offset+=1
 	return offset
@@ -202,8 +201,11 @@
 			#uniscribe does some strange things when you give it a string  with not more than two alphanumeric chars in a row.
 			#Inject two alphanumeric characters at the end to fix this 
 			lineText+="xx"
-			if NVDAHelper.localLib.calculateWordOffsets(lineText,len(lineText),offset-lineStart,ctypes.byref(start),ctypes.byref(end)):
-				return start.value+lineStart,min(end.value+lineStart,lineEnd)
+			try:
+				if NVDAHelper.localLib.calculateWordOffsets(lineText,len(lineText),offset-lineStart,ctypes.byref(start),ctypes.byref(end)):
+					return start.value+lineStart,min(end.value+lineStart,lineEnd)
+			except:
+				pass
 		#Fall back to the older word offsets detection that only breaks on non alphanumeric
 		start=findStartOfWord(lineText,offset-lineStart)+lineStart
 		end=findEndOfWord(lineText,offset-lineStart)+lineStart

# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWYyY2noAAfDfgGAyUG//93ZH
zYq////wUAS4aVUm9XbVtuiq6EooRPNJkhtqjynqaeU9GKM1PKADQBoAlEqfiNNMmk9TVH5QntJ6
pkAAAGjRoASSaTEmhkyGhNJo2SGEAA0BoMhzTEyZNGEwTE0wCYBDBGBGASSTQE9JpqntMphqYkNk
nqeU9R6aJpiAMkAToYYZhlEMGu0NfyRBm+0dI02JW0yIiyVT6h8cdk4TqjuVbB+vjTuWv33Mkzfj
tC5pVTbQ1t0L4Qabu90ZvFSvl8u7tlpftv/H+/Pfts+oThlassCypY62BwnE0btOZtBLrUGFlB8n
Bqb4vFarreIQgaJKvIPEG1H0GvoMCSI2HIZp2R+9vB1olVidnQBoGkwvRJtaFFdHc2ud1Oy3JuJp
HRBQbhpXkZIg5nYKNjqXoTsIkUNka2SGHouMlUnYmU4ZTsyQSgbTnZW45UeEUQgO6rJIg9rqWOcC
mWyx9ZS1O27jDLGGErjei2yovVzayxKgNgXR2Fsegx2XRbNCgk+1qrKh63ed7Gq0QmwNrcGCfne2
+NmhsjotKW3+KRVI8pRLITdFR0y6d+MpWFoZcg+8KQLC8rg3fCnBbdtkS6k8w6SqkLEaTMdeNhBS
BzDLW0H1bcrnjJPJvaiYvYohJbHm514xtbgjQsTDnldh+k4LbG0IpibjqrKsMJmuFkc09BfPSTN3
hWchNQSrXKOlg9tRpzMQM/g3ULf3rqE4vHDsNzLC7LbdnNT8zR3NLkqGByqCaU4SKBTEuBE1X25Z
nFFt5sd1gYwPLchUVV2bXSLzz3uwOYkPdaUKtiuJzBw4xEz9rwufv2S6UTZ4yjrD5QG2GHzqA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