--- includes/flag.export.inc.orig
+++ includes/flag.export.inc
@@ -15,9 +15,9 @@
  *   Optional. The name of the module that will be created if exporting to use
  *   in hook_flag_default_flags().
  */
-function flag_export_flags($flags = array(), $module = '') {
+function flag_export_flags($flags = array(), $module = '', $indent = '') {
   $output = array();
-  $output = '$flags = array();'. "\n";
+  $output = $indent . '$flags = array();'. "\n";
   foreach ($flags as $flag) {
     if (!is_object($flag)) {
       // We got just the flag name, for example from the features
@@ -41,10 +41,10 @@ function flag_export_flags($flags = array(), $module = '') {
     // Remove the flag ID.
     unset($new_flag['fid']);
 
-    $output .= '// Exported flag: "'. check_plain($flag->get_title()) . '"' . ".\n";
-    $output .= '$flags[] = ' . var_export($new_flag, TRUE) . ";\n";
+    $output .= $indent . '// Exported flag: "'. check_plain($flag->get_title()) . '"' . ".\n";
+    $output .= $indent . '$flags[] = ' . (function_exists('ctools_var_export') ? ctools_var_export($new_flag, $indent) : var_export($new_flag, TRUE)) . ";\n";
   }
-  $output .= 'return $flags;';
+  $output .= $indent . 'return $flags;';
   return $output;
 }
 
diff --git a/sites/all/modules/contrib/flag/includes/flag.features.inc b/sites/all/modules/contrib/flag/includes/flag.features.inc
index 70bbd29..66d94dc 100644
--- a/sites/all/modules/contrib/flag/includes/flag.features.inc
+++ b/sites/all/modules/contrib/flag/includes/flag.features.inc
@@ -46,7 +46,7 @@ function flag_features_export_options() {
  */
 function flag_features_export_render($module = 'foo', $data) {
   module_load_include('inc', 'flag', '/includes/flag.export');
-  $code = flag_export_flags($data, $module);
+  $code = flag_export_flags($data, $module, '  ');
   return array('flag_default_flags' => $code);
 }
 
